regex

regex in jquery

I need to provide the P.O Box validation for the address Fields Now we have a regex validation in jquery which has some limitations as follows: If an address polo Rd is given, it identifies "po" in polo and alerts error message. So, we should frame a new validation which should not accept address lines with the values: "PO BOX", "PO ...

NSString - Convert to pure alphabet only (i.e. remove accents+punctuation)

I'm trying to compare names without any punctuation, spaces, accents etc. At the moment I am doing the following: -(NSString*) prepareString:(NSString*)a { //remove any accents and punctuation; a=[[[NSString alloc] initWithData:[a dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] encoding:NSASCIIStringEncoding] a...

How to find the last HTML tag which has not closed using regular expressions?

Lets say I have this string $string = "<html> <body> <h1> <b>aaa</b> bbbb "; I want the result to be "h1" because it is the latest unclosed tag another example if the string is $string = "<body> <img src='' alt= "; the r...

Regex newbie question

Given this text "Foo(Bar)" I'd like to extract "Bar" using a regex. Help! ...

How to non-greedy multiple lookbehind matches

Source: <prefix><content1><suffix1><prefix><content2><suffix2> Engine: PCRE RegEx1: (?<=<prefix>)(.*)(?=<suffix1>) RegEx2: (?<=<prefix>)(.*)(?=<suffix2>) Result1: <content1> Result2: <content1><suffix1><prefix><content2> The desired result for RegEx2 is just <content2> but it is obviously greedy. How do I make RegEx2 ...

How to install/use RegexKitLite for an iPhone application?

I'm trying to understand how to get my iPhone application working with RegexKitLite, I tried searching Google for how to install it but couldn't find anything that explains it clearly. Hopefully this will become a step-by-step guide for anyone searching for it in the future. Alright so according to the documentation it says: The two...

Javascript Regex help for beginner

Hi, I need to validate the below range via regex in javascript. -20.00 to +20.00 with an increment of 0.5. The user should be able to enter the 1.50 as well instead of +01.50. I tried to do a lot of research in google, though regex is not easy. If I understand it correctly, then I will need to split up the regex into smaller grou...

Regular expression to match a time span

I want to parse data which might contain mixed patterns like 1-4pm 1pm-5pm noon to 11pm noon to midnight etc. I want to extract start and end time. How can I achieve this through regex. I know I can't support all possible input formats, but how can I achieve to support a maximum? ...

Help with regular expressions

Hello, I am new to c#. I need to write a method that takes a log file created by a compilation output and figures out the number of errors and warnings. I need to scan each line of the log and find the following match: x error(s), y warning(s) Examples of this patterns are: Compile complete -- 1 errors, 213 warnings 6>Process_M...

Javascript replace with reference to matched group?

I have a string, such as hello _there_. I'd like to replace the two underscores with <div> and </div> respectively, using javascript. The output would (therefore) look like hello <div>there</div>. The string might contain multiple pairs of underscores. What I am looking for is a way to either run a function on each match, the way ruby d...

find occurence of a set of words

Hi, I have a pattern with a small list of words that are illegal to use as nicknames set in a pattern variable like this: $pattern = webmaster|admin|webadmin|sysadmin Using preg_match, how can I achieve so that nicknames with these words are forbidden, but registering something like "admin2" or "thesysadmin" is allowed? This is the...

Ruby gsub / regex modifiers?

Where can I find the documentation on the modifiers for gsub? \a \b \c \1 \2 \3 %a %b %c $1 $2 %3 etc.? Specifically, I'm looking at this code... something.gsub(/%u/, unit) what's the %u? ...

How do I match and replace a non-word character between word characters with RegEx?

Hello, I am working with a data set that needs to be scrubbed. I am looking to replace the question marks(?) with the em-dash code(&mdash;). Here is an example string: "...shut it down?after taking a couple of..." I can match that instance with this expression: \w\?\w However, it matches one character on either side of the questi...

Getting the index of the substring on solaris

Hi. How can I find the index of a substring which matches a regular expression on solaris10? ...

Regex Help - Enforce 6 character string with at least TWO alpha chars and TWO numeric chars?

I need to enforace the following regex, and I'm horrible at writing these: xx12ab - valid x12345 - invalid xxxxx1 - invalid xxx123 - valid I need to have a 6 character string that HAS TO HAVE at least 2 alpha chars, and 2 numeric chars, limited to only alpha/numeric in the string. Thanks. ...

ruby regex .scan

I'm using Ruby's scan() method to find text in a particular format. I then output it into a string separated by commas. The text I'm trying to find would look like this: AB_ABCD_123456 Here's the what I've come up with so far to find the above. It works fine: text.scan(/.._...._[0-9][0-9][0-9][0-9][0-9][0-9]/) puts text.uniq.sort.joi...

Regexp for validating .au domain names

Hi, I need a quick regexp for validating that a string is a valid .au domain name. For example: xxx.com.au xxx.net.au xxx.org.au xxx.biz.au xxx.--.au all of these should be considered valid. This should be pretty simple for someone not as hopeless with regexps as I am. Any ideas? ...

Regex help for MediaWiki template markup

My regex skills are pretty poor, and most of the time they make me feel stupid. Can anyone help? This question is more concerned with better mastery of regex than the job of extracting information from mud soup, so if my understanding of the mediawiki template system is flawed, I don't really mind that much. I'll spot it soon enough. I...

Extracting text fragment from a HTML body (in .NET)

I have an HTML content which is entered by user via a richtext editor so it can be almost anything (less those not supposed to be outside the body tag, no worries about "head" or doctype etc). An example of this content: <h1>Header 1</h1> <p>Some text here</p><p>Some more text here</p> <div align=right><a href="x">A link here</a></div><...

Javascript RegExp does not work in IE

The parameter *return_value* contains <textarea>{"id":43,"description":"","item_id":28,"callback":"addNewAttachment","filename":"foo.jpg",,"type":"posts","ext":"jpg","size":145}</textarea> The next code removes the textarea tags in Firefox, Chrome, so the content can be accessed in arr[1]. In IE alert("Failure") is called. funct...