regex

PHP Email Array Regular Expression

Given a list of emails, formated: "FirstName Last" <[email protected]>, "NewFirst NewLast" <[email protected]> How can I build this into a string array of Only email addresses (I don't need the names). ...

How does the qr/STRING/ operator in Perl decide whether or not to compile STRING?

The docs for qr/STRING/ say: This operator quotes (and possibly compiles) its STRING as a regular expression. What worries me is the part in parentheses. I can't think of any cases where I don't want it to compile a regex out of STRING. Is this parenthetical statement just weasel words to cover some future case where compiling ...

python regex escape characters

Hi. We have: >>> str 'exit\r\ndrwxr-xr-x 2 root root 0 Jan 1 2000 \x1b[1;34mbin\x1b[0m\r\ndrwxr-xr-x 3 root root 0 Jan 1 2000 \x1b[1;34mlib\x1b[0m\r\ndrwxr-xr-x 10 root root 0 Jan 1 1970 \x1b[1;34mlocal\x1b[0m\r\ndrwxr-xr-x 2 root root 0 Jan 1 2000 \x1b[1...

regular expression - how to match an empty string

i want to match a string that can have any type of whitespace chars (specifically I am using PHP). or any way to tell if a string is empty or just has whitespace will also help! ...

How do I match valid words with a ruby regular expression.

Using a ruby regular expression, how do I match all words in a coma separated list, but only match if the entire word contains valid word characters (i.e.: letter number or underscore). For instance, given the string: "see, jane, run, r#un, j@ne, r!n" I would like to match the words 'see', 'jane' and 'run', but not the word...

regexp split string by commas and spaces, but ignore hyphenated words?

I need a regexp to split a string by commas and/or spaces, but ignore hyphenated words -- what's the best way to do this? so, for example -- I'd like this ... "foo bar, zap-foo, baz".split(/[\s]+/) to return ["foo", "bar", "zap-foo", "baz"] but when I do that it includes the commas like this ... ["foo", "bar,", "zap-foo,", "baz"...

regular expression for textarea

I am looking for a regular expression to filter out all \r\n out of the html file but if there is a textarea it should be passed without having the enter removed. I am using .NET (C#) technology. ...

How to find a word NOT preceded by another specific word?

Which regular expression can I use to find all strings bar are not preceded by string foo? Having whitespace between the two is also illegal. So the regex should match the following strings foo is bar hello bar But not these foobar foo bar I've tried using the following (?!<foo)bar and it gets the work done for eliminating ...

regex - match not in tag

this should be easy but somehow I can't figure it out: I have HTML snippet like this one: <p style="padding:0 10 20 30; margin: 1 2 3 4 ">This is 201 some 20 text 1 <b>30</b> with some numbers 30 20</p> ... I need to match numbers 1, 20, 30 (only those) and replace them with links. Obviously I do not want to replace numbers inside tag ...

python help display regular expression result

Hi, I am doing simple regular expressions in python I am trying the re.split but things like ['\r\n', '\r\n'] are coming instead of the answer. Can someone please tell me how to display the actual text please? I tried this statement: t_html = re.split("<[a-zA-Z0-9\s\w\W]*>[a-zA-Z0-9\s\w\W]*</[a-zA-Z0-9\s\w\W]*>" ,s) THanks ...

Regex Expression Problem...

I have the following regular expression /[^a-zA-Z0-9 ]/g I want include " in the following piece of code onKeyUp="this.value=this.value.replace(/[^a-zA-Z0-9"]/g,'') I used the above regex The problem I am facing over here is that the above regular expression allows me to include other special charaters (&, *, etc.) into it. How do...

How to use regEx to return false when data not in range?

Sample data: Hello I'm 301 I need a regex to allow A-Z a-z 0-9 and space(s) only. All other characters are not allowed. If detected, return false to javascript. Based on the sample data above, it should return false because got a character which is not accetable===> ' How to write this in js. ...

Regular expression for a string with a max length that contains a required part?

I'm not exactly a regex guru, so I have some difficulty finding a regular expression for the following case. I'd like to match a string of the form <prefix>$rolename$<suffix> (e.g. abc$rolename$def) that has a maximum length of 20. Both <prefix> and <suffix> can be empty and may contain any character. The $rolename$ part is required. S...

Matching part of regex

I must to match the stars(*), that satisfied such conditions: \*\S.*\S\* -> (for example *y text1 text2 u*) The problem is, that i want to match only this stars, if the condition is true, how can it be done(desirable in java:))(i have write so: Pattern params = Pattern.compile("\\*\\S.*\\S\\*"); but this matches stars and text bet...

What are the things to watch out for with case insensitive regex replace?

I have written the following code to do case insensitive replace in C#: Regex.Replace(textBoxText, Regex.Escape(findText), replaceText, RegexOptions.IgnoreCase); Just wanted to check, whether this is the right approach, or is there a better approach and whether I'm overlooking something that I should better be aware of....

Regex to find word on page including inside tags.

Thanks to Chetan Sastry I have this Regex code to parse my page for a list of words and add the TM to them. var wordList = ["jQuery UI", "jQuery", "is"]; var regExp = new RegExp("\\b" + wordList.join("\\b|\\b") + "\\b", "g"); var $elem = $("#divWithText"); $elem.html($elem.html().replace(regExp, "$&&trade;")); This Regex is almost wha...

Fitnesse Framework regular expressions possible?

Hi all, Is there an easy way in Fitnesse to check cells based on regex patterns? This should work for all the possible fixtures like "query table", "decision table" and so on. E.g. if results(rows) are returned from a query table it should be possible to match certain cells (columns) against a regex, not just a fixed string. I guess you...

Match a Query to a Regular Expression in SQL?

Hi! I'm trying to find a way to match a query to a regular expression in a database. As far as I can tell (although I'm no expert), while most DBMS like MySQL have a regex option for searching, you can only do something like: Find all rows in Column 1 that match the regex in my query. What I want to be able to do is the opposite, i.e.:...

PHP Regex HTML Assistance

I need to write a regular expression using php which parses the following code block and removes all <font> and </font> tags. <p align="left"><font face="Arial" size="1">February 22, 2007</font></p> <p align="left"><b><font face="Arial" size="4">2K Sports Announces Major League Baseball 2K7 Has Gone Gold </font></b></p> ...

Perl to PHP With s///;

In perl, I can do: 1 while $var =~ s/a/b/;, and it will replace all a with b. In many cases, I would use it more like 1 while $var =~ s/^"(.*)"$/$1/; to remove all pairs of double quotes around a string. Is there a way to do something similar to this in PHP, without having to do while (preg_match('/^"(.*)"$/', $var)) { $var = preg...