regex

Grepping only certain lines of files

I have a collection of files in a directory which I would like to search for a particular regular expression (=([14-9]|[23][0-9]), as it happens). But I only care when this pattern falls on the second, sixth, tenth, ..., 4n+2-th line. Is there a good way to do this? ...

PHP - Regex, remove font tag.

Could someone tell me why this isn't working please? $str = preg_replace("<font[^>]*>", '', $str); CMS is for flash and now the client wants to implement a html website. Need to remove evil inline font tags to show default styling. ...

PHP, Preg_replace (regex), replacing just the part of pattern in ( )?

Sorry for this basic question, but I've been looking over all the info about preg_replace I can find and I still can't figure this out.. I have a large string, like this, for example: $string= '# tjs { fassdaf } #fsk { fssf} # fskff { casf }'; And when I do this, it replaces the entire pattern, not just the part in ( ) as I expect i...

Javascript RegEx wont work, but works in c# (atomic subexpression)

I have a regex tested in Expresso, works like a charm. But when I try to use it in javascript it gave an error. Firebug says: invalid quantifier ?><div\b[^>]*>(?<DEPTH>)|<\/div>(?<-DEPTH>)|.?)*(?(DEPTH)(?!))<\/div> the regex: <div\b[^>]*>(?><div\b[^>]*>(?<DEPTH>)|</div>(?<-DEPTH>)|.?)*(?(DEPTH)(?!))</div> The regex matches nested...

Visual studio regex to match swallowed exceptions

I need a Visual Studio regex to match swallowed exceptions. This is as far as I got, but it still matches valid code like this: catch (ArgumentNullException) { //... throw; } catch:Wh*\(:Wh*.*Exception.*\):Wh*\{[:Wh*.*]*[^(throw:Wh*.*;)].* How can I fix this? Edit: Am I to take it from the comments that testing for the absence...

How can I find tag with regular expression. Python.

Possible Duplicate: RegEx match open tags except XHTML self-contained tags How can I find tag with regular expression. I have html like this: <div class='head'> Article TExt <div> <tag> Some ather text </tag> How mast looks like regular expression to find text inside tags DIV whith class 'head'? ...

Regex.split, how to read left of the matched pattern

I am trying to convert a Perl script to a C# 3.5 routine. The perl code I have is: if($work =~ /\<[0-9][0-9][0-9]\>/){ $left = $`; $match = $&; $work = $'; } In C# I wrote the following code: string[] sSplit = Regex.Split(work, @"\<[0-9][0-9][0-9]\>"); if sSplit.length is > 2 { left = sSplit[0]; ...

eregi_replace to preg_replace conversion

I have upgraded my php now i am getting warning messages for eregi_replace Can you please help me in converting following ereg expression to preg? $str = eregi_replace("[[:space:]]+", " ", $str); $text = eregi_replace('<a href=?([^ "\']*)>([^<]*)</a>', '<a href="\\1">\\2</a>', $text); $text = eregi_replace('<a href=(\')?([^ "\']*)(\')>...

How can you print all the characters that satisfy a regular expression?

Is there a way of printing out every character that satifies a given regular expression? For example, can I print all characters that matches regular expression, let's say, in Javascript: [A-Za-z_-]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\...

php regular expressions resources

Hi all , can somebody point me to a good regular expression resource (for php if it matters). I am looking now for a book here amazon but don't know which one is better. It would be great to find something simple to understand and a fast and interesting process of learning. ...

NSRegularExpression - no iPad support?

I want to use NSRegularExpression in my iPhone app, but Apple's documentation says that it was first available in iOS 4. Since iPads are still running on iOS 3.2 this means that my app would not be available for iPads -- correct? Is there any way to get around this? Or do I just need to wait until apple's iOS 4.1 release which should sup...

Help with multiline regex match

I am trying to have a regular expression match a value that spans multiple lines. I am using the re.S flag, but still get no results. Any ideas why? This is the text that I am searching through: <File id="abc.txt" EngRev="74"> <Identifier id="STRING_ID" isArray="1" goesWith="3027253"> <EngTranslation>"Value 1","Value 2","Value 3"...

java regular expression question

I want a regular expression that can match <FONT FACE=\"Verdana\" SIZE=\"12\"> My Name is xyz </FONT> or <LI><FONT FACE=\"Verdana\" SIZE=\"12\"> My Name is xyz </FONT></LI> and it should not be greedy ...

PHP regular expression skip element

I have written regular expression which converts text links into clickable link. The code works fine however when an HTML tag is passed it mess the code Here is my code $text = preg_replace('#(?<![">])((http|ftp)s?://[^<>\s]+)#i', '<a href="\\0">\\0</a>', $text ); It is suppose to skip following element <a href="http://www.yahoo.co...

Lookahead confusion

Ok i got this example from Regular Expression Cookbook ^(?=.{3}$).* The regex above is use to limit the length of an arbitrary pattern If i test again 'aaabbb', it completely fail From what i understand it look for any character that precede by any character 3 in length.SO it should match 'bbb' but its not One more question, should...

Regular expression for ignoring an optional comma

I have a text: $test = <<<START DOTHIS themsp1 @theint = 431, @theText = "%dumdum%", @operator = 'ANY', @crossCheck = 'PLUS' START; The filter: $regEx = '/@(.*)=(.*)[,]*?/'; preg_match_all($regEx,$test,$vars,PREG_SET_ORDER); print_r($vars); The Output: Array ( [0] => Array ( [0] => @theint ...

Generate Data for a Regex

Possible Duplicate: Random string that matches a regexp Hi, I have some regex's. Say I want to generate data in PHP that fit the individual regex. Here is an example: ^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,6}$ Found here for example. Now, how can I programmatically generate data that fits that regex? I would like to generate...

fetch content between _(" ") in ruby.

I want to fetch all the strings between _(" ") from my file. How may i fetch that? ...

Need help parsing some data in PHP

I need to be able to parse this sort of data in PHP: Acct: 1 email : [email protected] status : online -------------------------------------------------- Acct: 2 email : [email protected] status : banned -------------------------------------------------- Acct: 3 signedupname : SomeUsername ...

Need help with modifying an existing regex search extension

I would like to ramp on extension development by modifying an existing extension. I have zero experience with JavaScript, but i do have experience with C, C++, Java and Python. I chose the Regular Expression Search extension by bizsimon. Here is the JavaScript code of the content script which i am trying to understand. chrome.extension...