How do you comment a Perl regular expression?
How do you put comments inside a Perl regular expression? ...
How do you put comments inside a Perl regular expression? ...
I have generated the following regular expression in a project I am working on, and it works fine, but out of professional curiosity I was wondering If it can be "compressed/shortened": /[(]PRD[)].+;.+;.*;.+;.+;.*;.*;.*;/ Regexes have always seemed like voodoo to me... ...
I'm trying to create a small app that takes a base text template with specially tagged word arrays, parses the template contents and outputs a randomly generated text document. Essentially, what I'm trying to do is take this: <{Hello|Hi|Howdy}> world. and turn it into this: Hello world. OR Hi world. OR Howdy world. So far, so g...
I'm having some issues with parsing CSV data with quotes. My main problem is with quotes within a field. In the following example lines 1 - 4 work correctly but 5,6 and 7 don't. COLLOQ_TYPE,COLLOQ_NAME,COLLOQ_CODE,XDATA S,"BELT,FAN",003541547, S,"BELT V,FAN",000324244, S,SHROUD SPRING SCREW,000868265, S,"D" REL VALVE ASSY,000771881, S,"...
I use Zend IDE and quite often use Analyze code to quickly find undeclared or unused variables. As all PHP developers I also use regular expressions. So main question is where to set a checkbox or tune config file to disable these warnings: Bad escape sequence: \s (line NN) Thanks for answers! ...
I've been all over google and haven't been able to find a regex that would parse (correctly) CLI arguments. Does anyone have in their code library such a thing? Ideally it would parse all styles of arguments (i.e.: -v -abc --arg=val --arg="val1 val2" --arg "val") Thanks! P.S.: This would be used in PHP context (preg) ...
I am using Regex.Split to split a SQL script on the keyword "GO". My problem here is that I cannot seem to get my head around how to get the Regex to do the split. My regex expression also splits on "GO" even if it's in a SQL statement like: Insert into x(a,b) values(‘please go get some text’,’abc’) But I only want it to split on the...
I'm writing PHP code to parse a string. It needs to be as fast as possible, so are regular expressions the way to go? I have a hunch that PHP string functions are more expensive, but it's just a guess. What's the truth? Here's specifically what I need to do with the string: Grab the first half (based on the third location of a substrin...
Anyone know why this is happening: Filename: 031\_Lobby.jpg RegExp: (\d+)\_(.*)[^\_e|\_i]\.jpg Replacement: \1\_\2\_i.jpg That produces this: 031\_Lobb\_i.jpg For some reason it's chopping the last character from the second back- reference (the "y" in "Lobby". It doesn't do that when I remove the [^_e|_i] so I must b...
I'm trying to create a function that will take a string which could be over multiple lines, e.g.: "declare notThese declare orThis hello = $notThis@butthis$ butNot= $ButNotThis$ andDefNot = getDate()" And search through it, pulling out {string1}'s from all parts like ${whatever}@{string1}$ and then pushing them into an array. H...
i'm running out of ideas on the best regex implementation for this problem. Sample user input: bla bla bla http://foo.com bla bla bla http://tinypic.com/boo.png bla bla bla Looking for solution that will detect non-image url and turn it into a link and also turn image url into an image embed (IMG tag). so the output will be: bla bla...
What regex can take any of the lines below as input rtsp://server/blabla/bla RTSP/1.0 rtsp://server/blabla/bla/ rtsp://server/blabla/bla rtsp://server/blabla/bla/streamid=65335 RTSP/1.0 and always returns: rtsp://server/blabla/bla In general I have an arbitrary URL which always starts with "rtsp://" and optionally ends with EOL, "/...
I am trying to find out how many regex matches are in a string. I'm using an iterator to iterate the matches, and and integer to record how many there were. long int before = GetTickCount(); string text; boost::regex re("^(\\d{5})\\s(\\d{8})\\s(.*)\\s(.*)\\s(.*)\\s(\\d{8})\\s(.{1})$"); char * buffer; long length; long count; ifstream ...
Is it possible to count how many times a substring appears in a string using regex matching with GNU libc regexec()? ...
Let's say I have a big RSS feed full of Twitter posts, and they are all plain text. Lots of the posts contain URLs, and I'd like those URLs to be turned into links. So I've got a variable that is equal to: Visualization of layoffs by industry, number and date. Looking forward to seeing similar for hiring trends. http://bit.ly/XBW...
I have a variable containing html string. This string has this particular code <a href="http://www.pheedo.com/click.phdo?s=xxxxxxxx&amp;p=1"><img border="0" src="http://www.pheedo.com/img.phdo?s=xxxxxxxxxx&amp;p=1" style="border: 0pt none ;" alt=""/></a> Using regex, how can I remove that. Basically looking for the phe...
I'm looking for a javascript regex that will remove all content wrapped in quotes(and the qoutes too), in a string that is the outlook format for listing email addresses. Take a look at the sample below, I am a regex tard and really need some help with this one, any help/resources would be appreciated! "Bill'sRestauraunt"BillsRestauraun...
Are Python and JavaScript regular expression syntax identical? If not, then: What are the important differences between them Is there a python library that "implements" JavaScript regexps? ...
In PHP, I want to encode ampersands that have not already been encoded. I came up with this regex /&(?=[^a])/ It seems to work good so far, but seeing as how I'm not much of a regex expert, I am asking if any potential pitfalls can be seen in this regex? Essentially it needs to convert & to & but leave the & in & as is (so as...
I have a source code in Fortran (almost irrelevant) and I want to parse the function names and arguments. eg using (\w+)\([^\(\)]+\) with a(b(1 + 2 * 2), c(3,4)) I get the following: (as expected) b, 1 + 2 * 2 c, 3,4 where I would need a, b(1 + 2 * 2), c(3,4) b, 1 + 2 * 2 c, 3,4 Any suggestions? Thanks for your time... ...