regex

Regular exp to validate email in C

Hi, We need to write a email validation program in C. We are planning to use GNU Cregex.h) regular expression. The regular expression we prepared is [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])? But the below code is failing while compiling the r...

C# regex: negative lookahead fails with the single line option

I am trying to figure out why a regex with negative look ahead fails when the "single line" option is turned on. Example (simplified): <source>Test 1</source> <source>Test 2</source> <target>Result 2</target> <source>Test 3</source> This: <source>(?!.*<source>)(.*?)</source>(?!\s*<target) will fail if the single line option is on...

notepad++ regular expression

Hi Guys, I need your help. I have two lines like below: /pace =builtin\administrators Type=0x0 Flags=0x13 AccessMask=0x1f01ff /pace =domain\user Type=0x0 Flags=0x13 AccessMask=0x1f01ff Need to create a regular expression where it only select "0x1f01ff" where the line have "domain\user". This is what I have created but it select "/p...

php regex - can't find the error

Just one simple, specific question: I've got the string {var1}12345{var2}, and I want to get the variable names used. if (preg_match("/{([a-zA-Z0-9]*)}/g", $url, $matches)) { print_r($matches); } If I remove the global flag, it works, but I only get the first variable, as expected. Why isn't it working with a global flag? It works...

Server-side validation in ASP.NET 2.0

Hi All, My application is in ASP.NET 2.0 with C#. I have a regular expression validator with the regular expression ^[0-9]*(\\,)?[0-9]?[0-9]?$, now my client don't want this validation at client side but on button click i.e. Server Side. EX: I have to check the value of txtPrice textbox Please let me know how can I put this regular ex...

.net Regular Expression to match any kind of letter from any language

Which regular expression can I use to match (allow) any kind of letter from any language I need to match any letter including any diacritics (e.g. á, ü, ñ, etc.) and exlude any kind of symbol (math symbols, currency signs, dingbats, box-drawing characters, etc.) and punctuation characters. I'm using asp.net MVC 2 with .net 4. I've trie...

Problem with basic regex to match ending optional character

Hi all i was hoping someone could help be with some basic regex i am really struggling with. Bascially i need to match a url for redirection. I have been using ^~/abc(/)? however i need to change the end part to just check the last optional character as this will also match ^/abcd ...

Regex in JavaScript

Suppose we don't know how many slashes we could get in a string but we do not want any extra slashes. So if we get this string '/hello/world///////how/are/you//////////////' we should transform it to the form of '/hello/world/how/are/you/'. How to do it with the help of regular expressions in JavaScript? ...

How can I use Perl regular expressions to parse XML data?

I have a pretty long piece of XML that I want to parse. I want to remove everything except for the subclass-code and city. So that I am left with something like the example below. EXAMPLE TEST SUBCLASS|MIAMI CODE <?xml version="1.0" standalone="no"?> <web-export> <run-date>06/01/2010 <pub-code>TEST <ad-type>TEST <cat-code...

C# Regular Expression - Why some char not in it validate the IsMatch() condition :(

Hi, I use this regular expression for validating some of my textbox : Regex re = new Regex("^([äö\x20\x27\x2C\x2D\x5Fò-öà-âù-üç-ï0-9a-zA-Z]+)$"); And when i put "<" or ">" in one of this textBox, my condition shoud be false and not true :) if (re.IsMatch(TextBox.Text)) /*do something */ else Console.write("error invalid char in text...

.NET RegEx for letters and spaces

I am trying to create a regular expression in C# that allows only alphanumeric characters and spaces. Currently, I am trying the following: string pattern = @"^\w+$"; Regex regex = new Regex(pattern); if (regex.IsMatch(value) == false) { // Display error } What am I doing wrong? ...

What Regex can strip e.g. "note:" and "firstName: " from the left of a string?

I need to strip the "label" off the front of strings, e.g. note: this is a note needs to return: note and this is a note I've produced the following code example but am having trouble with the regexes. What code do I need in the two ???????? areas below so that I get the desired results shown in the comments? using Sy...

Javascript reg ex to match whole word only, bound only by whitespace.

Hi, so I know \bBlah\b will match a whole Blah, however it will also match Blah in "Blah.jpg" I don't want it to. I want to match only whole words with a space on either side. ...

url.rewrite-once with Kohana and with urls

currently I have this setup in our simple-hosts.conf: url.rewrite-once = ( ".*.(js|ico|gif|jpg|png|css|php|htm)(?.*)?$" => "$0", "/slapi" => "/slapi/index.php" ) Works great, except the above fails when I have a dot in the query string: ?url=http://google.com My regexpy is not 1337 ...

How to remove the first & last slash from a url if it's exists?

Hi I use parse_url() to get the path of a url but i want to remove the first slash & the last if it's exists. Example: "/posts/funny-dog/" -> "posts/funny-dog" "/" -> "" // Because http://www.google.com/ path is a slash "/categories/politic" -> "categories/politics" Thanks ...

Sed non greedy curly braces match

I have a string in a file a.txt {moslate}alho{/moslate}otra{moslate}a{/moslate} a need to get the string otra using sed. With this regex sed 's|{moslate}.*{/moslate}||g' a.txt a get no output at all but when i add a ? to the regex s|{moslate}.*?{/moslate}||g a.txt (I've read somewhere that it makes the regex non-greedy) i get n...

Regular expression for a string containing one word but not another

I'm setting up some goals in Google Analytics and could use a little regex help. Lets say I have 4 URLs http://www.anydotcom.com/test/search.cfm?metric=blah&amp;selector=size&amp;value=1 http://www.anydotcom.com/test/search.cfm?metric=blah2&amp;selector=style&amp;value=1 http://www.anydotcom.com/test/search.cfm?metric=blah3&amp;selecto...

Jeditable doubling up on linebreaks every edit

I'm using var retval = value.replace(/<br[\s\/]?>/gi, '\n'); To strip the <br> tags from the textarea and nl2br('$_POST('newValueHere')') to insert into my database and to return back to jeditable to display the edits. The only problem I'm having is that each click on the editable field seems to make all the <br> tags be written twic...

RFC822: email address validation with regular expressions

as you know, this is how we validate an email address: (?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t] )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?: \r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:( ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|...

regex help using repreated groups

I'm trying to match rc-update -s output in python. m = re.match(r"^\s*(\w+)\s*\|{\s*(\w+)\s*}*$", " network | level1 level2 leveln ") but m is always None the hard part for me is getting the regex to match the n levels. I thought that using {}* would match the n levels, but as soon as I add the {} nothing matches. thanks. ...