regex

Separate firstname and lastname from fullname string in C#

I'm doing a website migration that involves extracting firstname and lastname from fullname. Given these were created by the end user, all kinds of permutations exist (although English and generally not too strange). Mostly I can take the first word as firstname and the last word as the lastname but have some exceptions from the occasi...

Regex to remove apostrophe

I have input text that contains a ' like in this text "Frank's Reel Movie Reviews" how do I get rid of the ' I have tried .replace (/\'/ig, ''); .replace ('\'', ''); But it seem like the ' does now want to be deleted... I am thinking that the ' maybe encoded utf-8 or something Any ideas ...

What would be the regex to add commas to long digits for legibility?

I want to convert 2333444 to 2,333,444, but I'm not clear on how to have the expression work its way from the right to the left as opposed to the other way around. I'm writing Perl, but any regEx syntax is fine, I'll convert it if you are more comfortable with java or javascript. ...

Regex question - advanced

Here is another Regex questions for the experts I am building an Mysql insert with regex... This is what the insert looks like... so far (#text1#,#text2#,#text3#,#text4#,#text5#,#text6#, #text7#, #text8#, #text9#), (#text1#,#text2#,#text3#,#text4#,#text5#,#text6#, #text7#, #text8#, #text9#), (#text1#,#text2#,#text3#,#text4#,#text5#,#t...

Is it possible to shortcut a regular expression into matching?

I have a few regular expressions which are run against very long strings. However, the only part of the string which concerns the RE is near the beginning. Most of the REs are similar to: \\s+?(\\w+?).* The REs capture a few groups near the start, and don't care what the rest of the string is. For performance reasons, is there a way t...

regular expression: find and replace each match

I need to change the elements that surround some contents in a string, leaving the content as is. I'm doing it with a regular expression, but when I replace using the positional parameter ($1), it only uses the first match. For example, if I have this string: <strong>I want</strong> to change <i>this</i> text, ...

How to add or replace a query string parameter in classic ASP?

I have a set of links in header.asp which is included on every page; these links have their href attribute set to whatever the current page is plus a linkID param. Sometimes the page the link references will have query string params, but other times it won't. If the current page URL contains the linkID param already I need to replace it,...

find and replace

Hello, Find: regexp1 **sometext** regexp2 Replace with: newregexp1 **sometext** newregexp2 Here, I do not want **sometext** to be modified. That is to say, if I have the following lines in a file: Hello somebody! Have a good day. Hello somebodyelse! Have a good day. I want the output to be: Bye somebody! Good night. Bye so...

How to validate a user name with regex?

This seems to match the rules I have defined, but I only starting learning regex tonight, so I am wondering if it is correct. Rules: Usernames can consist of lowercase and capitals Usernames can consist of alphanumeric characters Usernames can consist of underscore and hyphens and spaces Cannot be two underscores, two hypens or two sp...

How to loop all the elements that match the regex?

Here is the case: I want to find the elements which match the regex... targetText = "SomeT1extSomeT2extSomeT3extSomeT4extSomeT5extSomeT6ext" and I use the regex in javascript like this reg = new RegExp(/e(.*?)e/g); var result = reg.exec(targetText); and I only get the first one, but not the follow.... I can get the T1 only, b...

Need a regex that will check if the string only consist letters a-z and numbers and underscore(_) and hyphen(-)

I'm looking for a regex that will check if the string only consists of the letters a-z, numbers, underscore (_) and hyphen (-). I have tried this, but it does not work: if (!preg_match('/^a-zA-Z0-9_-$/', $string)) { $reg_Error[] = 2; } Also, can I check the length with regex? If not, I will just do it with PHP. ...

regex help for validators

I need a regular expression validator to validate that text fields contain only numbers between 00 - 31 (note that it should allow both 05 and 5), another regex for numbers 01 -12 (again, it should allow both 05 and 5), and another regex for numbers between 1920 - 2009. How can i do this? ...

preg_replace PHP

I know this is really easy, and I've done it a million times myself; but it's late in the day and I have a brain meltdown. I'm trying to match and replace whole words rather than every occurance. So, I want to replace each occurance of the word 'me' and replace it with 'xxx' Ie. 'Me meets smeg' becomes 'xxx meets smeg' What I DO NOT ...

Perl qr// and substitution.

Hi guys. I'm writing a tiny program that takes user input using Getops, and based on it, the program will either try to match a pattern against some text, or substitute text for what matched. The problem I'm having is that I can't get the substitution portion to work. I'm looking at the qr// entry in the man pages: http://perldoc.perl....

Regex for unclosed HTML tags

Does someone have a regex to match unclosed HTML tags? For example, the regex would match the <b> and second <i>, but not the first <i> or the first's closing </i> tag: <i><b>test<i>ing</i> Is this too complex for regex? Might it require some recursive, programmatic processing? ...

diff in mod rewrite on apache 1.3 and 2.2

What is the difference in mod_rewrite between Apache 1.3(.37) and 2.2(.11)? RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^pages/edit(account|page)/([0-9]+)*$ ./index.php?p=edit$1&id=$2 RewriteRule ^pages/([\w'-]+)*$ ./index.php?p=$1 I wrote this and it "works on my machine" which...

php regex to read select form

Hi, I have a source file with a select form with some options, like this: <option value="TTO">1031</option><option value="187">187</option><option value="TWO">2SK8</option><option value="411">411</option><option value="AEL">Abec 11</option><option value="ABE">Abec11</option><option value="ACE">Ace</option><option value="ADD">Addikt</op...

identify tense in php

Hi, I'm looking for a way to analyze a string of text and find out in which tense it was written, for example : "I'm going to the store" == current, "I bought a car" == past ect.. Any tips on how I could this done? ...

Need REGEXP Matching in MySQL

I want to match a String which looks like this: [lang_de]Hallo![/lang_de][lang_en]Hello![/lang_en]HeyHo[lang_es]Hola![/lang_es] I want the matching to return true if there is text which is not enclosed by lang_tags (in this example: HeyHo). It could also be positioned at the beginning or end of the string. Whitespace should NOT match...

Help with PHP Regular Expressions using a Negative Look Behind

Hello, I'm trying to write a simple function to close missing HTML tags using PHP preg_replace. I thought it would be relatively straight-forward, but for some reason it hasn't been. What I'm basically trying to do is close a missing tag in the following row: <tr> <th class="ProfileIndent0"> <p>Global pharmaceuticals</p> <td>197...