regex

Replace all escape sequences with non-escaped equivalent strings in java

I have a string like this: &lt;![CDATA[&lt;ClinicalDocument&gt;rest of CCD here&lt;/ClinicalDocument&gt;]]&gt; I'd like to replace the escape sequences with their non-escaped characters, to end up with: <![CDATA[<ClinicalDocument>rest of CCD here</ClinicalDocument>]]> ...

How to get rid of duplicates in regex

Suppose I had a string, "cats cats cats and dogs dogs dogs." What regular expression would I use in order to replace that string with,"cats and dogs." i.e. removing duplicates. The expression however must only remove duplicates that follow after each other. For instance: "cats cats cats and dogs dogs dogs and cats cats and dogs dogs" ...

Using RE to retrive an ID

Hello, I am trying to use RE to match a changing ID and extract it. I am having some bother getting it working. The String is: m = 'Some Text That exists version 1.0.41.476 Fri Jun 4 16:50:56 EDT 2010' The code I have tried so far is: r = re.compile(r'(s*\s*)(\S+)') m = m.match(r) Can anyone help extract this string. Thanks ...

java regular expression

I am trying to write a regular expression for somethin like s1 = I am at Boston at Dowtown s2 = I am at Miami I am interested in the words after at eg: Boston, Downtown, Miami I have not been successful in creating a regex for that. Somethin like > .*? (at \w+)+.* gives just Boston in s1 (Downtown is missed). it just matches the...

How to deal with Polish Characters while using regex ?

I have street name as KRZYWOŃ ANIELI and so what should be my regex to allow this kind of expression. Currently I have simple one which uses /^[a-zA-Z ]+$/ Kindly advise. ...

regex based profiling in java

I've heard that there is an integrated facility in java to do profiling with regex based profiling point definitions. I'm however not able to find any info on the net. Does anybody know about such a possibility or anything similar? ...

I'm Stuck with a simple lighttpd url.rewrite

Hello, Just switched from apache and having some rewrite issues. Simple task: rewrite "http://www.foo.com/BAR/" to "http://www.foo.com/BAR/index.php" I've tried the following (and variations) but it doesn't parse. url.rewrite = ( "/BAR/" => "/BAR/index.php" ) I suck in regexps btw. ...

Changing FileNames using RegEx and Recursion

Hello I'm trying to rename files that my program lists as having "illegal characters" for a SharePoint file importation. The illegal characters I am referring to are: ~ # % & * {} / \ | : <> ? - "" What i'm trying to do is recurse through the drive, gather up a list of filenames and then through Regular Expressions, pick out file name...

Why does this regular expression fail?

I have a password validation script in PHP that checks a few different regular expressions, and throws a unique error message depending on which one fails. Here is an array of the regular expressions and the error messages that are thrown if the match fails: array( 'rule1' => array( '/^.*[\d].*$/i', 'Password must co...

Regex for zeroing in on build output text error

I'd like to quickly hone in on what failed in a build log output that is nearly 5k lines long, using Notepad++ as my editor for the file. Notepad++ has the nice ability to specify regular expressions, so I am wondering if there is a way to not match: Compile complete -- 0 errors, 0 warnings but to match, for example: Compile complete...

Shell scripting to perform regex match/replace

I'm using cURL to get a web page and present to our users. Things have worked well until I came upon a website using considerable amounts of Ajax that's formatted so: 33687|updatePanel|ctl00_SiteContentPlaceHolder_FormView1_upnlOTHER_NATL| <div id="ctl00_SiteContentPlaceHolder_FormView1_othernati...

Regex age verification

Anyone have a good regex for Age verification? I have a date field where I am validating that what the user enters is a date. basically I wanted to figure out if that date is valid, and then further refine the date to be within x number of years Perhaps this may be too complicated to tack onto whatever I have too far, but I figured ...

How can I make this Perl regex work?

I have this line /Od /D "WIN32" /D "_DEBUG" /FD /EHa /MDd /Fo"Debug" /Fd"Debug\vc80.pdb" /W3 /c /Zi /clr /TP .\main.cpp" And I want to extract the .\main.cpp. I thought the following would do the trick: if($string =~ /.*\s+(.*)$/i) { print "matched ",$1,"\n"; } because this same regex works in Ruby, and extracts the string I requi...

Objective C - RegexKitLite - Parsing inner contents of a string, ie: start(.*?)end

Please consider the following: NSString *myText = @"mary had a little lamb"; NSString *regexString = @"mary(.*?)little"; for(NSString *match in [myText captureComponentsMatchedByRegex:regexString]){ NSLog(@"%@",match); } This will output to the console two things: 1) "mary had a little" 2) "had a" What I want is just the 2nd bit ...

regex unicode charater in vim

I'm being an idiot. Someone cut and pasted some text from microsoft word into my lovely html files. I now have these unicode characters instead of regular quote symbols, (i.e. quotes appear as <92> in the text) I want to do a regex replace but I'm having trouble selecting them. :%s/\u92/'/g :%s/\u5C/'/g :%s/\x92/'/g :%s/\x5C/'/g .....

nginx - redirect a certain path to another domain

Hey there. I am very unfamiliar with nginx, as a forewarning, and also can't find any actual references on the regex system they use. So right now it's a black box to me. All I want to do is redirect a user trying to go to www.mydomain.com/mydirectory/X to www.myotherdomain.com/X . Seems like I should be using the rewrite command but ...

PHP preg_match: a pattern which satisfies all MySQL field names (including 'table.field' formations)

i need a pattern which satisfies mysql field names, but also with the option of having a table name before it examples: mytable.myfield myfield my4732894__7289FiEld here's what i tried: $pattern = "/^[a-zA-Z0-9_]*?[\.[a-zA-Z0-9_]]?$/"; this worked for what i needed before, which was just the field name: $pattern = "/^[a-zA-Z0-9_]...

Python regular expression help

Hi SO, I can't seem to create the correct regular expression to extract the correct tokens from my string. Padding the beginning of the string with a space generates the correct output, but seems less than optimal: >>> import re >>> s = '-edge_0triggered a-b | -level_Sensitive c-d | a-b-c' >>> re.findall(r'\W(-[\w_]+)',' '+s) ['-edge_0...

Validating forms with regex in codeigniter

How can I validate a form using regex in codeiginiter. I'd like to check the input against: ^([0-1][0-9]|[2][0-3]):([0-5][0-9])$ I'm assuming the best way is in some sort of callback. I tried a bunch of ideas on the web but I can't seem to get any working. ...

how to escape slashes in perl text used in a regular expression?

end_date=$(date +"%m/%d/%Y") /usr/bin/perl -pi -e "s/_end_date_/${end_date}/g" filename I want to replace string '_end_date_' with current date. Since current date has slashes in it(yes I want the slashes), I need to escape them. How can I do this? I've tried several ways like replacing slashes with "\/" using sed and perl itself but ...