regex

Regular Expression matching anything after a word

I am looking to find anything that matches this pattern, the beginning word will be: organism aogikgoi egopetkgeopt foprkgeroptk 13 So anything that starts with organism needs to be found using regex. ...

Different behavior between re.finditer and re.findall

Hello, I am using the following code: CARRIS_REGEX=r'<th>(\d+)</th><th>([\s\w\.\-]+)</th><th>(\d+:\d+)</th><th>(\d+m)</th>' pattern = re.compile(CARRIS_REGEX, re.UNICODE) matches = pattern.finditer(mailbody) findall = pattern.findall(mailbody) But finditer and findall are finding different things. Findall indeed finds all the matches...

std::bad_cast crash seems to be linked to boost_regex

I've gotten the exact same code compiled on Ubuntu and am now trying to get my program working on a MacOS 10.6.4. I installed boost 1.4.4 as root using ./bootstrap.sh and then ./bjam I also performed the following: ./bjam install variant=debug define=_GLIBCXX_DEBUG --with-regex I compiled the program using Codeblocks (without any erro...

Is RegEx used by System.Net.Mail.MailAddress

I have been trying to find a good RegEx for email validation. I have already gone through Comparing E-mail Address Validating Regular Expressions and that didn't suffice all my validation needs. I have Google/Bing(ed) and scan the top 50 odd results including regular expressions info article and other stuff. So finally i used the Syste...

python validate text

I need to check that text contain only small letters a-z and , best way to do it in python? ...

Help with regular expression in javascript

Hi, I need a regular expression that would split strings like itemXY where X and Y are integer (item23) to be used in javascript. I would like it to return the integers x and y. Thanks ...

Does anyone know of a reg expression for uk date format

Hi does any one know a reg ex for a uk date format e.g. dd/mm/yyyy. The dd or mm can be 1 character e.g. 1/1/2010 but the year must always be 4 characters. Thanks in advance ...

Regex - match a string, but only where the next word is not 'x'

If I have this string: "The quick brown fox jumped over the lazy dog. What a nice brown fox that is." What regex would I use to match the text 'brown fox' but not where the following word is 'that', i.e. (matches in italic): "The quick brown fox jumped over the lazy dog. What a nice brown fox that is." ...

how to a regex for similar string

i have this string [url=test.php]test[/url] or [url=http://test.php]text[/url] I want to a regex get this [url=http://test.php]text[/url] example: before: str = "[url=test.php]text[/url]" str.gsub(/\[url=(.*?)\](.*?)\[\/url\]/,'[url=http://\1]\2[/url]') => "[url=http://test.php]text[/url]" question: str = "[url=http://test....

ereg_replace to preg_replace for a particular regex

I've converted some eregs to preg_matches by replacing the initial ^ and final $ with /s (I hope that was sufficient), but I have an ereg_replace in the same function that I'm not sure about. It's from a checkPostcode function to be found here. // Take account of the special BFPO c/o format $postcode = ereg_replace ('C\/O', 'c/o ', $po...

PHP: Conditional charset replace in preg_replace

I have a site scraped into $html variable. now i want to replace some chars with this expression $string1 = preg_replace('/[^A-Za-z0-9äöü!&_=\+-]/i', ' ', $string); The Problem is there are special characters caused by different charsets. I have a variable $charset in which the charset string of the page is saved. i.e. $charset="utf...

Python regular expressions: search and replace weirdness

I could really use some help with a Python regular expression problem. You'd expect the result of import re re.sub("s (.*?) s", "no", "this is a string") to be "this is no string", right? But in reality it's "thinotring". The sub function uses the entire pattern as the group to replace, instead of just the group I actually want to r...

PHP Regex Problem:

$string1 = preg_replace('/[^A-Za-z0-9äöü!&_=\+-]/', ' ', $string4); This Regex shouldn't replace the chars äöü. In Ruby it worked as expected. But in PHP it replaces also the ä ö and ü. Can someone give me a hint how to fix it? ...

Regular Expressions in MS Access VBA?

I definitely like MS Access as an RAD-Tool for small-scope data-driven applications. But one thing I really miss as a .Net-Developer is Regular Expressions. They really come in handy when validating user input. I really do not know why Microsoft did not put these in the standard VBA-Library. Is there a way to use Regular Expressions in...

Can someone tell me the purpose of the second capture group in the jQuery rts regular expression?

In Jeff Roberson's jQuery Regular Expressions Review he proposes changing the rts regular expression in jQuery's ajax.js from /(\?|&)_=.*?(&|$)/ to /([?&])_=[^&\r\n]*(&?)/. In both versions, what is the purpose of the second capture group? The code does a replacement of the current random timestamp with a new random timestamp: var ts ...

Regex to return unique lines when pattern matched

I am parsing a log file and trying to match error statements. The part of the line I am matching "error CS" will apply to numerous lines some duplicates some not. Is there a way I can not return the duplicates. Using Java flavor of RegEx.. example: my simple regex returns Class1.cs(16,27): error CS0117: 'string' does not contain a ...

What does this Perl regex mean: m/(.*?):(.*?)$/g ?

I am editing a Perl file, but I don't understand this regexp comparison. Can someone please explain it to me? if ($lines =~ m/(.*?):(.*?)$/g) { } .. What happens here? $lines is a line from a text file. ...

How can I substitute one substring for another in Perl?

I have a file and a list of string pairs which I get from another file. I need substitute the first string of the pair with the second one, and do this for each pair. Is there more efficient/simple way to do this (using Perl, grep, sed or other), then running a separate regexp substitution for each pair of values? ...

Regex process using cut(Linux)(sh)

Hello people, I'm having a problem with regex in using the command sh cute, the problem is that I want to show all processes that start with g and just show the command, but do not know, help me please? To do this I use the command: ps aux | grep g but this show all process who contains the letter g and i need who start with g and c...

Java Unicode Regular Expression

I have some text like this. Every person haveue280 sumue340 ambition I want to replace ue280, ue340 to \ue280, \ue340 with regular expression Is there any solution Thanks in advance ...