regex

How to match "any character" in Java Regular Expression?

The following should be matched: AAA123 ABCDEFGH123 XXXX123 can i do: ".*123"? ...

Regular expression only for website

Hi, I'm new to Regular Expressions. I need to find just website in some text and I'm looking for a regular expression able to find out strings like: www.my.home, http://my.site.it But this regular expression should not find strings like: [email protected] or if the website is already inside html tag <a href="http://www.my.site.com...

Find Methods in a c# File programmatically

Hi Friends, I want to write a code to search for method defination and methods called in a c# file. So obviously my pattern should search for text like 1.public void xyz(blahtype blahvalue); 2.string construct = SearchData(blahvalue); Has anyone done similar to this, is Regex helpful in this case. if yes provide me the pattern. Any...

regular expression help

I always get confused using regular expressions. Can anyone please suggest me a tutorial? I need help with checking for a string which, cannot contain any wild characters except colon, comma, full stop. It will be better to replace these if found. Any help? Thanks. ...

regex to match letters, numbers, certain symbols

I need to validate a username in php, it can be: Letters (upper and lower case) Numbers Any of these symbols :.,?!@ up to 15 characters OR 16 if the last character is one of the following #$^ (it can also be 15 or less with one of these 3 characters at the end only) How do I do this? ...

Php and python regexp difference?

I need to parse a string 'Open URN: 100000 LA: ' and get 100000 from it. on python regexp (?<=Open URN: )[0-9]+(?= LA:) works fine but in php it gives following error: preg_match(): Unknown modifier '[' I need it working php, so please help me to solve this problem and tell about difference in python and php regexps. ...

LINQ and REGEX.REPLACE

I am trying to pull address records out of a database and group them together by address. Simple enough right? The problem I has is the LOCATION field is formatted as such BUILDING: some building description ADDRESS: 555 1st Street or BUILDING: some building description ADDRESS: 555 1st STREET There are multiple instances wher...

regular expression breaking on new line

I'm trying to use a regular expression as below: preg_match_all('|<table.*</table>|',$html,$matches, PREG_SET_ORDER); But this is not working, and I think the problem is the new line inside the string $html. Could someone tell me a work around? EDIT: I've realized that it's not right to use regex to parse HTML. Thanks to those who to...

RegEx: h1 followed by h2 without p in between

Hey everyone, I need a regular expression to find out whether or not a h1 tag is followed by a h2 tag, without any paragraph elements in between. I tried to use a negative lookahead but it doesn't work: <h1(.+?)</h1>(\s|(?!<p))*<h2(.+?)</h2> ...

DOM manipulation

Hello everyone, Im trying to use the DOM in PHP to do a pretty specific job and Ive got no luck so far, the objective is to take a string of HTML from a Wordpress blog post (from the DB, this is a wordpress plugin). And then out of that HTML replace <div id="do_not_edit">old content</div>" with <div id="do_not_edit">new content</div>" i...

Regex to repeat a capture across a CDL?

I have some data in this form: @"Managers Alice, Bob, Charlie Supervisors Don, Edward, Francis" I need a flat output like this: @"Managers Alice Managers Bob Managers Charlie Supervisors Don Supervisors Edward Supervisors Francis" The actual "job title" above could be any single word, there's no discrete list to work from. Replaci...

Using a regex pattern to find revision numbers from a svn merge

svn diff -rXX:HEAD Will give me a format like this, if there has been a merge between those revisions: Merged /<branch>:rXXX,XXX-XXX or Merged /<branch>:rXXX I'm not very familiar with regex and am trying to put together a pattern which will match all the numbers (merged revision numbers) AFTER matching the "Merged /branch:r" part. ...

python re.search invalid expression even though it works on PHP and various other regex matchers

Hi, date = re.search(r'<td>([\x\d\w-.\s,()&\"]+|)<br><font',page_data) I am migrating a code from PHP to Python, and am using this piece of regex expression on re.match, which doesn't work, giving a python error of: raise error, v # invalid expression It works on PHP's preg_match, and also http://www.gskinner.com/RegExr , any idea ...

Help to convert PostgreSQL dates into SQL Server dates

Hello I'm doing some data conversion from PostgreSQL to Microsoft SQL Server. So far it has all went well and I almost have the entire database dump script running. There is only one thing that is now messed up: dates. The dates are dumped to a string format. These are two example formats I've seen so far: '2008-01-14 12:00:00' and the...

PHP preg_match Math Function

I'm writing a script that will allow a user to input a string that is a math statement, to then be evaluated. I however have hit a roadblock. I cannot figure out how, using preg_match, to dissallow statements that have variables in them. Using this, $calc = create_function("", "return (" . $string . ");" ); $calc();, allows users to inp...

PHP - regular expression to remove beginning and end chars from a string?

Let's say I have a string like so: $file = 'widget-widget-newsletter.php'; I want to use preg_replace() to remove the prefix widget- and to remove the suffix .php . Is it possible to use one regular expression to achieve all this? The resulting string should be widget-newsletter. ...

Regular Expression to parse SQL Structure

I am trying to parse the MySQL data types returned by "DESCRIBE [TABLE]". It returns strings like: int(11) float varchar(200) int(11) unsigned float(6,2) I've tried to do the job using regular expressions but it's not working. PHP CODE: $string = "int(11) numeric";<br/> $regex = '/(\w+)\s*(\w+)/';<br/> var_dump( preg_split($...

Efficiently Combine MatchCollections in .Net Regex

In the simplified example, there are 2 Regular Expressions, one case sensitive, the other not. The idea would be to efficiently create an IEnumerable collection (see "combined" below) combining the results. string test = "abcABC"; string regex = "(?<grpa>a)|(?<grpb>b)|(?<grpc>c)]"; Regex regNoCase = new Regex(regex, RegexOptions.Ignore...

Regex to validate SMTP Responses

I'm writing a regular expression that can interactively validate SMTP responses codes, once the SMTP dialog is completed it should pass the following regex (some parentheses added for better readability): ^(220)(250){3,}(354)(250)(221)$ Or with(out) authentication: ^(220)(250)((334){2}(235))?(250){2,}(354)(250)(221)$ I'm trying to ...

How can I use a regular expression to match something in the form 'stuff=foo' 'stuff' = 'stuff' 'more stuff'

I need a regexp to match something like this, 'text' | 'text' | ... | 'text'(~text) = 'text' | 'text' | ... | 'text' I just want to divide it up into two sections, the part on the left of the equals sign and the part on the right. Any of the 'text' entries can have "=" between the ' characters though. I was thinking of trying to match ...