regex

I am searching for a string like Cityname, State in mysql table where state name is 2 letter char.

I am searching for a string like Cityname, State (e.g.Moline,IL) in mysql table. How can i make the query using regexp in mysql. ...

RegEx to ignore / skip everything in html tags

Looking for a way to combine two Regular Expressions. One to catch the urls and the other to ensure is skips text within html tags. See sample text below functions. Need to pass a block of news text and format text by wrapping urls and email addresses in html tags so users don't have to. The below code works great until there are alread...

Python: Convert format string to regular expression

The users of my app can configure the layout of certain files via a format string. For example, the config value the user specifies might be: layout = '%(group)s/foo-%(locale)s/file.txt' I now need to find all such files that already exist. This seems easy enough using the glob module: glob_pattern = layout % {'group': '*', 'locale'...

Regular Expression for $_GET query strings

Hi there! I'm trying to find a regular expression for $_GET query strings. I have an array like this: private $_regexp = array( ':id' => '[0-9]+', ':year' => '[12][0-9]{3}', ':month' => '0[1-9]|1[012]', ':day' => '0[1-9]|[12][0-9]|3[01]', ':slug' => '[a-zA-Z0-9-]+', ':query' => '...' ); and I loop thro...

How can I generate all possible permutations from a Perl regular expression?

I know you can generate all permutations from a list, using glob or Algorithm::Permute for example - but how do you generate all possible permutations from a regular expression? I want to do like: @perms = permute( "/\s[A-Z][0-9][0-9]/" ); sub permute( $regex ) { # code - put all permutations of above regex in a list return @l...

Regex to match partial words (JavaScript)

I would like to craft a case-insensitive regex (for JavaScript) that matches street names, even if each word has been abbreviated. For example: n univ av should match N University Ave king blv should match Martin Luther King Jr. Blvd ne 9th should match both NE 9th St and 9th St NE Bonus points (JK) for a "replace" regex that wraps t...

Regex to match month name followed by year

Is it possible to use a regex to match "February 2009", for example? ...

Looking for: C/C++ Regex library that supports Named Captures

I'm thinking about writing a small application that will help me mass rename files. I currently use an application named 'RegexRenamer', which (I'm assuming) uses the .NET regex engine. The application is fine, but is sort of clunky. So what I'm looking for is a C/C++ regex library that I can build my custom program off of. Anything th...

Replace xml tag with regex

How can I replace a certain part in a xml file with a definied string? <tag1></tag2> <tag2></tag2> ...etc <soundcard num=0> <name>test123</name> </soundcard> <soundcard num=1> <name>test123</name> </soundcard> <soundcard num=2> <name>test123</name> </soundcard> <tag5></tag5> replace all soundcard parts that the result looks like th...

.ics Calendar File - Parsing Date Time - What is the time format?

I am coding in php, attempting to get the start\end dates and times for events. I am utilizing the following RegEx for parsing out the information: $pattern='/(?P<StartDate>[0-9]{8})T(?P<StartTime>[0-9]{6}) .+(?P<EndDate>[0-9]{8})T(?P<EndTime>[0-9]{6})/'; The sample event entry is here: BEGIN:VEVENT UID:34b09fd7-8e6e-4d56-86b0-445745...

Getting the last backslash in a filepath via regex

Given a file path such as: \\server\folder_A\folder_B\etc\more.mov I need a regex that'll give me the last backslash so I can extract the actual file name. My attempt of "$\\" is not returning anything. I'm using coldfusion. Suggestions...? ...

Replace named group in regex with value

I want to use regular expression same way as string.Format. I will explain I have: string pattern = "^(?<PREFIX>abc_)(?<ID>[0-9])+(?<POSTFIX>_def)$"; string input = "abc_123_def"; Regex regex = new Regex(pattern, RegexOptions.IgnoreCase); string replacement = "456"; Console.WriteLine(regex.Replace(input, string.Format("${{PREFIX}}{0}${...

Is there a more modern regexp handler for Open Object Rexx

The regular expression class (rxregexp.dll) that comes with ooRexx (I'm on 4.0.0) is relatively low on function compared, say, with Python's re module (even at 2.5.2). It appears to have no assertions, no facilities for group extraction, or for substitution. Greedy or lazy matching is a global pattern option, rather than flagged by an a...

how can i use RegExp to grap data from this site ?

Possible Duplicate: RegEx match open tags except XHTML self-contained tags i want to grap data from this site using RegExp http://www.islamqa.com/en/ref/20494 specially data in div with class="subject-container" i tried this /<div class="subject-container">(.*?)<\/div>\s*/is but it gave me Invalid RegExp why? ...

Java - Reg. Ex. File Question

I'm grabbing lines from a text file and sifting line by line using regular expressions. I'm trying to search for blank lines, meaning nothing or just whitespace. However, what exactly is empty space? I know that whitespace is \s but what is a line that is nothing at all? null (\0)? newline (\n)? I tried the test harness in the Java tu...

Insert a newline character every 64 characters using Python

Using Python I need to insert a newline character into a string every 64 characters. In Perl it's easy: s/(.{64})/$1\n/ How could this be done using regular expressions in Python? Is there a more pythonic way to do it? ...

Regular expressions

Hello guys! I need a regular expression for findin a pattern. This is the pattern: id|name|code|mobile I created a pattern for this if I want to search by id (if id = 1): .*1.*|.*|.*|.* But it matches every pattern that contains number 1. What's the problem with it? ...

Java Regexp patterns have double backslashes, how to store patterns in readable format

Would be great to have convenient way of storing patterns with single backslash. Some workarounds: store it in the file and use NIO to read. Cons: JEE does not allow IO access. Store somehow in JNDI. Maybe new to java 5 Pattern.LITERAL flag can help? I want to work with normal pattern string, like \d, not \\d. ...

Regular Expression

Ohh! this regular expression thing is eating my brain up. I have been reading it from Introduction to Automata Theory, Languages and Computer by Hopcroft, Motwani and Ullman. I have solved a few exercises too but could not solve the following even after trying for almost one hr. The problem is to write a regular expression that defines...

Regular Expression in Java

I have an HTML page and I want to fetch the result between two tags <b> and <BR>: <b>Defendants Name:</b>Donahue, Leah A <BR> What is the regular expression to fetch the words between these two tags? ...