regex

Java Regexp: UNGREEDY flag

Hi, I'd like to port a generic text processing tool, Texy!, from PHP to Java. This tool does ungreedy matching everywhere, using preg_match_all("/.../U"). So I am looking for a library, which has some UNGREEDY flag. I know I could use the .*? syntax, but there are really many regular expressions I would have to overwrite, and check th...

Regex which ignores comments

Hi, being a regex beginner, I need some help writing a regex. It should match a particular pattern, lets say "ABC". But the pattern shouldn't be matched when it is used in comment (' being the comment sign). So XYZ ' ABC shouldn't match. x("teststring ABC") also shouldn't match. But ABC("teststring ' xxx") has to match to end, that ...

Regex commas to spaces

i need a regex that converts commas to spaces. I know this is super simple, but i do not know regex. thanks. tag1, tag2, tag3, tag4,tag5 tag6 to tag1 tag2 tag3 tag4 tag5 tag6 thanks ...

Replace strings in file

Hi, I have to replace in a following manner if the string is "string _countryCode" i have to replace it as "string _sCountryCode" as you can see where there is _ I replace it with _s followd be next character in capitals ie _sC more examples: string _postalCode to be replaced as string _sPostalCode string _firstName to be replace a...

regex / instr javascript function to check url

Hi I have 8 possible URL structures that I need to check in my javascript code and then run a function if the current page meets the correct criteria. There are 8 possible variations of the URL and all will include the keyword questions, so the first check needs to isolate and identify if the current page has the keyword 'questions' in...

Locale-aware Perl regular expressions (matching word boundaries)

I'm currently somewhat stuck getting a regular expression in Perl (taken from an earlier question of mine) to match word characters from a non-ASCII locale (i.e., German umlauts). I already tried various things such as setting the correct locale (using setlocale), converting data that I receive from MySQL to UTF8 (using decode_utf8), an...

Regex pattern to return text from within brackets..

Hi, i am looking for a regex pattern that will return me the contents of the first set of brackets in a string. Eg - text text text text (hello) text (hello2) (hello3) text ..will return "hello" does anyone know what the pattern looks like for c#? ...

How can i give password validation in flex

I want the validator for password text input. At least one Upper case letter At least one numeric character At least one special character such as @, #, $, etc. should be there in password how can i give it in action script or mxml.please help me. Thanks. ...

Check if a string contains a certain number

I have a string 8,7,13,14,16 Whats the easiest way to determine if a given number is present in that string? $numberA = "13"; $string = "8,7,13,14,16"; if($string magic $numberA){ $result = "Yeah, that number is in there"; } else { $result = "Sorry."; } Looking for magic. ...

Extracting info from html using PHP(XPath), PHP/Python(Regexp) or Python(XPath)

I have approx. 40k+ html documents where I need to extract information from. I have tried to do so using PHP+Tidy(because most files are not well-formed)+DOMDocument+XPath but it is extremely slow.... I am advised to use regexp but the html files are not marked up semantically (table based layout, with meaning-less tag/classes used every...

Regex 2 digits separated by commas, not all required

I need a regex for the following input: [2 digits], comma, [two digits], comma, [two digits] The 2 digits cannot start with 0. It is allowed to only enter the first 2 digits. Or to enter the first 2 digits, then a comma en then the next 2 digits. Or to enter the full string as described above. Valid input would be: 10 99 17,56 15,99 ...

How to verify regexp patterns ?

What are the common ways to verify the given regex pattern works well of the given scenario and check the results ? I would like to know in general , not in the particular programming language and what is the best way to learn about writing regular expression ? ...

Getting spaces with Boost::regex

I have a chunk of text like: Name=Long John Silver;Profession=cook;Hobby=Piracy And using the Boost::regex library I am trying to get the value of each attribute so I have the following regular expression for Name: regex(".*Name=([^;$]*).*") I understand it as "get everything after Name= until you find a ; or the end of line". How...

How to match a string with an optional part?

We have a string that we need to parse using regex, the string could be either: There was a problem at XXXX There was a problem at XXXX, previous failures were YYY The XXX could be any character (e.g. ".") How can we make regex that will match: XXXX ", previous failures were YYY" (remember could be optional) Every regex that I t...

popluating multiple id tags

How can i populate multiple id tags simultaneously. On my page i have id tags starting with "total_" phrase, like total_1, total_2 etc., is there a way by which i can populate each of them on a single click in javascript. Should i use regex or parser. Any help will be highly appreciated. Thank you. ...

to remove href attr from all the anchor tags using Reg Ex

i am trying to remove href attr from all the anchor tags using Reg Ex,for print page. Although i need the text value in anchors. ...

Pulling RegEx from MySQL into PHP

I am trying to get the regex string from a table, but as soon as I put it into preg_match it throws an error about an unexpected "\". If I use the exact same string directly there is no issue. ...

RegEx Pattern to Match Only Certain Characters

I'm a newbie to RegEx, and this particular issue is flummoxing me. This is for use with a JavaScript function. I need to validate an input so that it matches only this criteria: Letters A-Z (upper and lowercase) Numbers 0-9 The following additional characters: space, period (.), comma (,), plus (+), and dash (-) I can write a patter...

Dealing ASP.net Routes with n slashes using regex

I need to use a URL like this: http://mydomain.com/Box/Categ1/Categ2/Categ3/.../CategN/id1,id2,id3,...,idN Then I tried to create a new route this way... routes.MapRoute( "Box", "Box/{data}", new { controller = "Box", action = "Index"}, new { data = @"([a-zA-Z0-9-,]+/?)+" } ); But it just doesn't work. If I use any c...

finding instance of text in sql files after WHERE clause

Hi guys, I have a VS2008 solution with a database project, in it is a folder that holds a whole bunch of sql stored procedures (we are talking 100's). Due to a change that has been made to the ANSI_NULLS setting for all the sprocs I need to update all instances of '= null' to 'is null'. I cannnot do a "find and replace all" on .sql fi...