regex

can you tell me what this regular expression means?

hi im new to regular expressions and would like to decipher this. return preg_replace("/[<>]/", '_', $string); thanks!! ...

QTP Using Regular Expressions to match object text dynamically

Let's say we're trying to match SSNs, so the regular expression would be: d{9}. But what if, at run time, I wanted to have, say, the third digit match to 3? So the regex would be d{2}3d{6}. I know that in QTP, you can use regex to match the text property of an object in the Object Repository, but how do I change that regex in QTP code...

Regular Expression to find words (using word boundary) where words include a dash character

Given the following Regular Expression: \b(MyString|MyString-Dash)\b And the text: AString MyString MyString-Dash Running a match against the text never finds a match for the second thing (MyString-Dash) because the '-' (dash) character isn't a word boundary character. The following javascript always outputs "MyString,MyString" to t...

Regular expression performance in Java -- better few complex or many simple?

I am doing some fairly extensive string manipulations using regular expressions in Java. Currently, I have many blocks of code that look something like: Matcher m = Pattern.compile("some pattern").matcher(text); StringBuilder b = new StringBuilder(); int prevMatchIx = 0; while (m.find()) { b.append(text.substring(prevMatchIx, m.start()...

REGEX: Trying to create a reg. exp. that can find a string in the referrers host name

I am trying to create a JavaScript regular expression that can find a keyword in the referrers host name. It cannot be in the file path, just the host name. So... these should pass: http://keyword.com/ http://www.keyword.com/ http://keyword.example.com/ http://examplekeyword.com/ But these should not: http://example.com/keyword http:...

check for valid email address

Possible Duplicate: What is the best regular expression for validating email addresses? hello, can you help with my coding? my problem is this: when the user wants to register, and when he entered his email. how can i check if it is valid or not? i use this code. please help me. tell me if its correct because i'm only a ...

How do I do this replace regex in python?

Given a string of text, in Python: s = "(((((hi abc )))))))" s = "***(((((hi abc ***&&&&" How do I replace all non-alphabetic symbols that occur more than 3 times...as blank string For all the above, the result should be: hi abc ...

php convert 1000 to 1,000.00

I was wondering if there is any php function to convert the number of 1000 to 1,000.00, 10000 to 10,000.00 and so on . I can write a regex but I just want to know if there is any php build in function like floor . ...

Consecutive, conflicting regex substitutions

I've tried this for the italics: r = re.compile(r"(\*[^ ]+\*)") r.sub(r'<i>"\1"</i>', foo) but it doesn't work, as I am sure anyone in the regex know will see right away. ...

Allow only letters; no punctuation no numbers

Hey guys can you help me with this. I've got this '/[^A-Za-z]/' but cannot figure out the punctuations part. Gracious! ...

Java Regex to remove start/end single quotes but leave inside quotes

I have data from a CSV file that is enclosed in single quotes, like: 'Company name' 'Price: $43.50' 'New York, New York' I want to be able to replace the single quotes at the start/end of the value but leave quotes in the data, like: 'Joe's Diner' should become Joe's Diner I can do updateString = theString.replace("^'", "").repl...

Extracting number ID from a URL in Javascript

Similar to my previous question: http://stackoverflow.com/questions/3300433/spliting-a-string-in-javascript The URLs have now changed and the unique number ID is no longer at the end of the URL like so: /MarketUpdate/Pricing/9352730/Report How would i extract the number from this now i cannot use the previous solution? ...

I need to match strings that don't contain a keyword at an arbitrary position.

I need to match strings that don't contain a keyword (beta2) at an arbitrary position. Consider: var aStr = [ '/beta1/foo', 'beta1/foo', '/beta1_xyz/foo', 'blahBlah/beta1/foo', 'beta1', '/beta2/foo', 'beta2/foo', ...

Find particular lines and wrap them with <b>

Hi! I want to wrap particular lines in a text mass with <b></b> First line in the text All lines with a previous empty line (eg two newlines before) I'm using preg_replace with php, but I'm really shitty with regex. Good tutorials are appreciated. ...

Batch file - matching file extensions.

Probably far too easy question, but how do I match a file extension such as .jpg while not matching jpg~ (i.e. a jpg that a program has made a local copy of?) My current line is: for /f %%a in ('dir /b *.jpg') do echo %%~na But if any program has a copy of one of the files open (and thus has made a .jpg~ file) this regexp will match t...

Regex: How to replace with the string literal "\1"?

I have a string, say r"a". I want to replace every r"a" with the string r"\1", but my regex engine does not understand this. I have tried: r"\1" -- crashes (can't match group 1 because there is no group 1) r"\\1" -- crashes (not sure why) Is this a limitation of my (proprietary) regex engine, or is it a general problem? Is there an ...

How do I catch strings that don't start with "ajax/" using regex for CodeIgniter?

I'm working on some routes for my CodeIgniter application, and I need to declare a 'catch-all'/except one regular expression. Any route that doesn't start with 'ajax/' should be redirected to the 'main'-router. Like so: $route['regexmagichere'] = "main"; So this is definetly way beyond my regex skills and I need some help. The regex s...

Perl regular expression and capture buffer numbering

I have a file that contains hundreds of lines of the form long long int FILE_FORMAT_HEADER.file.index 1.4 3 I don't care about anything except those two numbers at the end: 1.4 and 3. I'm using the following regular expression: $line =~ m/.+\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)/ The idea being to read as much...

Should I be able to quote a leading or trailing dollar sign ($) inside a word boundary in Java Regular Expression?

I'm having trouble getting regular expressions with leading / trailing $'s to match in Java (1.6.20). From this code: System.out.println( "$40".matches("\\b\\Q$40\\E\\b") ); System.out.println( "$40".matches(".*\\Q$40\\E.*") ); System.out.println( "$40".matches("\\Q$40\\E") ); System.out.println( " ------ " ); System.out.println( "40$"...

re.sub issue when using group with \number

Hi, i'm trying to use a regexp to arrange some text, with re.sub. Let's say it's an almost csv file that I have to clean to make it totally csv. I replaced all \t by \n doing : t = t.replace("\n", "\t") ... and it works just fine. After that, I need to get some \t back to \n, for each of my CSV lines. I use for that this expression...