regex

Can I use regex_t for several compilations

Hi, Basic question, not clear to me for the regcomp man. If I have a static instance of regex_t, can I reuse it for several compilation without freeing it every time, something like: int match(char* pattern, char* name) { static regex_t re; regcomp(&re,pattern,REG_EXTENDED|REG_NOSUB); ... } The code itsel...

Regex to pull out querystring variables and values

I am using Javascript and trying to break out query string variables from their values. I made a regex that works just fine IF there are no other ampersands except for denoting variables, otherwise the data cuts off at the ampersand. example: ajax=10&a=test&b=cats & dogs returns a = "test", b = "cats " I cannot encode the ampersands b...

Awk pattern matching

I want to print userId = 1234 userid = 12345 timestamp = 88888888 js = abc from my data messssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss <input name="userId" value="1234" type="hidden"> messsssssssssssssssssss <input name="userid" value="12345" type="hidden"> messssssssssssssssssss <input name="timestamp" valu...

regex - date format OR not specified/empty

Hi, I have a regex problem that I need some advice on. I am using a jquery plugin that validates input fields on a JSP. I am using the date validation. It all works fine but this field is not required and is not marked as required. When the user hits submit it shows a warning on the date input field since the empty string does not m...

Regular expression to match a date range

Does anyone have any ideas on if/how one could create a regular expression to match a date in any given period? Two examples: 23/11/2008 - 12/04/2010 //The expression would evaluate whether 16/04/2010 was in this range, and return false. //The expression would determine whether 03/12/2009 was in this range, and return true. and 01/...

How to decompile a regex?

Is there any way to decompile a regular expression once compiled? ...

createuserwizard refuese to add users due to password

When working with the the createuserwizard control, I found it always showed a "select a different password" message (in the example InvalidPasswordErrorMessage="Parola trebuie sa contina minim 7 caractere." ) when I try to add a user. The passwordregularexpression property is empty by default, I also tried to change it to some simple...

Mysql field name within regular expression

I have the following table Table bots{ ip_address varchar(15), bot_name varchar(32) } Given that some bots have static ips and others won't, the table has entries such as 192.168.0 and 192.168.1.15 Now I have to see if a given ip belongs to a bot. I was thinking something along these lines SELECT bot_name FROM bots WHERE __i...

Trying to find Twitter RT's with Regular Expressions and PHP

I'm trying to find the correct Regular Expression to match all RT scenarios on Twitter (can't wait to Twitter's new retweet API). The way I see it, RT's can be at the beginning, middle, or end of the string returned from Twitter. So, I need something at the beginning and end of this Regular Expression: ([Rr])([Tt]) No matter what I...

Help needed: Finding a string pattern using regular expressions

My input string is: "<!--<clientHtml>--><br><br><br><b>Job Title:</b> Test text <br><b>JobId:</b> 56565-116503 <br><br><b>City:</b> San Diego <br><b>State:</b> CA <br><b>Zip Code:</b> 92108 <br><br><br><b>Description:</b> We are recruiting for a Controller to oversee all accounting and finance for a growing manufacturing co...

C# Regex Compatibility Issue (.NET 3.5 vs .Net 2.0)

I have the following regex expression on a dev machine that is running .NET 3.5 and it works as designed. However when it is deployed to our test environment (which is running .NET 2.0) it doesn't work right and always seems to return false. Does anyone know what the culprit may be? Thanks using System.Text.RegularExpressions; prote...

isolating a match with regular expressions and PHP

Hi all still struggling with regex :) i have this code: $link = '/\bhttp:\/\/.+\..+[\/\w]?\b/i'; $match = array(); if (preg_match($link, 'http://bit.ly/hghjK6 bla bla',&$match)) { echo 'match'.'</br>'; print_r($match); } as i'm trying to extract only the URL from the string i cant isolate it and the value inserted into $match ...

Using preg_replace to trim variable in PHP

I want to extract text from $_SERVER['HTTP_REFERER'] let's say $_SERVER['HTTP_REFERER'] = http://www.google.com/search?source=ig&amp;hl=en&amp;rlz=&amp;q=something+i+am+looking+for&amp;aq=f&amp;oq=&amp;aqi= then I want $query equal "something+i+am+looking+for". I figure I can use pregreplace so I can say $query=preg_replace([some re...

match "[" with ruby regular expressions

I want to match a string that includes the characters 0-9.-,[], something like this: return true if str =~ /\A[0-9.-,\[\]]*\Z/ Which works except it doesn't seem to match the braces, how do I match those? ...

How do I check that a form is pre-populated with values using Cucumber and Webrat?

I am learning Cucumber and Webrat with Rails and would like some advice on the best way to test an "edit" form. When I browse to a user's profile I am presented with an edit form with the user's information pre-populated in the form fields. I would like to be able to test that the fields do in fact contain the information I expect. Here'...

Regular expression for splitting by char which might be escaped

I need to split a string similar to a path, which is delimited by dots. The tricky part is that the each subentry may also contain dots, which are escaped by another dot. Each entry may otherwise contain basically anything (including special characters such as space or :;/\|(), etc..) Two examples: "Root.Subpath.last/entry:with specia...

ASP Regular Expression for UK Telephone format in VB.net

Hi, I want regular expression validator for my telephone field in VB.net. Please see the requirement below: Telephone format should be (+)xx-(0)xxxx-xxxxxx ext xxxx (Optional) example my number would appear as 44-7966-591739 Screen would be formatted to show +44-(0)7966-591739 ext Please suggest. Best Regards, Yuv ...

How to validate data restriction using regex in java

Hi I want to validate a string which donot have numeric characters. If my string is "javaABC" then it must be validated If my string is "java1" then it must not be validated I want to restrict all the integers. So how can I restrict using regex in java Thanks Sunil Kumar Sahoo ...

Trouble with positive look behind assertion in python regex.

Hi, Trying to use a reasonably long regex and it comes down to this small section that doesn't match how I'd expect it to. >>> re.search(r'(foo)((?<==)bar)?', 'foo').groups() ('foo', None) >>> re.search(r'(foo)((?<==)bar)?', 'foo=bar').groups() ('foo', None) The first one is what I'm after, the second should be returning ('foo', 'b...

String replaceAll() vs. Matcher replaceAll() (Performance differences)

Pretty simple question, but this is coming from a C/C++ person getting into the intricacies of Java. I understand I can fire up jUnit and a few performance tests of my own to get an answer; but I'm just wondering if this is out there. Are there known difference(s) between String.replaceAll() and Matcher.replaceAll() (On a Matcher Objec...