regex

how to catch python syntx error

try: pattern=r'<tr><td><a href='(?P<link>[\s\S]*?)'[\s\S]*?><img src='(?P<img>[\s\S]*?)' width='130' height='130'[\s\S]*?/></a></td>' except: try: pattern=r"<tr><td><a href='(?P<link>[\s\S]*?)'[\s\S]*?><img src='(?P<img>[\s\S]*?)' width='130' height='130'[\s\S]*?/></a></td>" except: pattern=r"""<tr><td><a ...

Needed C++ HTML parser + regular expression support

I'm working on a C++ project and I need to find an external library which provides HTML parser and regular expression support. The project is under 2 OS - iOS & Android. I was thinking using libxml2 which has a HTML parser module and xml regular expression. Can I use the xml regular expression module on HTML page? In addition, I need...

match url pattern in php using regular expression

I want to match a url link in wall post and replace this link with anchor tag, for this I use the regular expression below. I would like the match 4 types of url: http://example.com https://example.com www.example.com example.com preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1<...

Php format numbers in a string with regexp

Hello, I need help with writing a regular expression in PHP. I am not friend enough to get it right. I need to find all integers in a string and format them as follows: 1 to 001000 0.13 to 000130 100 to 0100000 and so on. In normal speech it means - edit the number prepend it with zeros or edit it to be in same "order". The point is...

regular expression help

Hay i have a string like [gallery GALLERYNAME] [gallery GALLERYNAME] the GALLERYNAME indicates a name of a gallery What would a regular expression looks like to match this string? ...

How do you regex match some unicode character follow by bracket?

I am not too familiar with regex and hope someone could help. example: This is a sentence with some_unicode[some other word] and other stuff. After removing the characters and brackets, the result should be: This is a sentence with and other stuff. Thank you!! ...

What kind of strings does this regex match ?

Please give me examples of text which match this regex: root/(.+)-go-to-products.php ...

Regex required: To return substring which is present after first completion of parentheses.

Example- 1)(abc)xxx --> output-xxx 2)(abc)(xxx) --> output-xxx 3)((abc)xxx) ---> output-xxx 4)((abc) xxx + yyy)--> output-xxx+yyy 5)((abc)) ---> output-null ...

Get valule regular expression

I have this regular expression: company/(.*)-f(\d+).html$ company/view/$2 In view method of company class I use $this->uri->segment(3) to get the value of $2; I can't understand why can't get the value of $2 just like variable. public function view($param) { echo $param; // no value returned $this->uri->segment(3) // works fine }...

How to remove repeating non-adjacent string

Given lines that look like the following: Blah \cite[9.1173]{Joyce:1986aa}\autocite[42]{Kenner:1970ab}\autocite[108]{Hall:1960aa} bbb.\n I’d like to remove the second (and any subsequent) occurrence of \autocite, resulting in the following: Blah \autocite[9.1173]{Joyce:1986aa}[42]{Kenner:1970ab}[108]{Hall:1960aa} bbb.\n I’m struggling...

Match parameter values in string using regex

I have a string containing several parameters, e.g. PARAM1="someValue", PARAM2="someOtherValue"... For log-output I want to "hide" some of the parameter's values, i.e. replace them with ***. I use the following regex to match the parameter value, which works fine for most cases: (PARMANAME=")[\w\s]*" However, this regex only match...

Multiline regexp matcher

There is input file with content: XX00002200000 XX00003300000 regexp: (.{6}22.{5}\W)(.{6}33.{5}) Tried in The Regex Coach(app for regexp testing), strings are matched OK. Java: pattern = Pattern.compile(patternString); inputStream = resource.getInputStream(); scanner = new Scanner(inputStream, charsetName);...

How Can i Call methods from a regex string.

In one of my project i need to call methods dynamicly depending upon the regular expression a string. in one of my case i have this string. And(Answered(ARef(16350,100772,null)),Not(AnyOf(ARef(16350,100772,null),[Closed temporarily])),Not(AnyOf(ARef(16350,100772,null),[Closed down]))) which will like this if arrange it to understa...

Multiline regexp with <? and ?> ?

here is my code : <html> titi <? print "toto"+"<br>" ?> <html> and i want only the lines between the <? and ?> the only regexp thaht i've found was : <?.*\n*?\?> but it lacks the first <? so if anyone have any idea it drives me nuts ... Regards and thanks for all people. Bussiere ...

php Match and replace

Hi, I want to replace every link I find within a string, with a modified version of the string, say for example: The quick brown fox jumped over the http://www.google.com/?v=abc and http://www.google.com/?v=x_y-z I would replace (and modify) the links in this so it becomes: http://www.google.com/v/abc and http://www.google.com/v/x...

Need help with boost regexp library

I'm trying to port a code from PHP to C++. I was using the PHP build-in regular expression to extract some value and it works well. From some reason the same reg expression does not work when using the boot regexp library. Could anyone spot what I'm doing wrong: reg exp: regex exp("__EVENTVALIDATION" value="(.*)"); and the string is:...

How can I manipulate just part of a Perl string?

I'm trying to write some Perl to convert some HTML-based text over to MediaWiki format and hit the following problem: I want to search and replace within a delimited subsection of some text and wondered if anyone knew of a neat way to do it. My input stream is something like: Please mail <a href="mailto:[email protected]&amp;Subject=Please ...

java replace regex a-z0-9 only

I would like to show only a-z0-9 in a string, and the other characters should be replaced by null string String s=this.saveFileName.replaceAll("/[a-z0-9. ]/", ""); This those not work, any ideas why? ...

python regex question

Hello, What is the correct regex statement using re.search() to find and return a file extension in a string. Such as: (.+).(avi|rar|zip|txt) I need it to search a string and if it contains any of those avi, rar, etc) return just that extension. Thanks! EDIT: should add that is needs to be case insensitive ...

Rails, Radiant, and Regex

I'm working on a Rails site that uses the Radiant CMS and am building stateful navigation as per the first method in this link. I'm matching the URL on regular expressions to determine whether or not to show the active state of each navigation link. As an example, here are two sample navigation elements, one for the Radiant URL /commu...