regex

How to allow only "numbers","-" and "()" using JavaScript

Hello, I have to do phone number validation using JavaScript. I have already done validation for numbers as follows, var filter =/^[0-9]+$/ But now I have to also allow hyphen and "()". Please provide me a way for the same. ...

Regular expression for validating a username?

I'm still kinda new to using Regular Expressions, so here's my plight. I have some rules for acceptable usernames and I'm trying to make an expression for them. Here they are: 1-15 Characters a-z, A-Z, 0-9, and spaces are acceptable Must begin with a-z or A-Z Cannot end in a space Cannot contain two spaces in a row This is as far as...

Regex Help needed.

Hi All, I've a String template which I need to process using regex. I need to get the list of #if #endif blocks from the below template. I tried the following regular expression String regexIfEndIf="\\#if(.*)\\#endif"; But the below code Pattern pattern=Pattern.compile( regexIfEndIf,Pattern.DOTALL); Matcher matcher=pattern.matcher( t...

Regular Expressions...

How would I extract the word 'wrestle' from the following: type=weaksubj len=1 word1=wrestle pos1=verb stemmed1=y priorpolarity=negative using a regular expression? Thanks ...

Boost Libraries: Unable to link regex library on MAC OS X

I'm trying to use the Boost Libraries ... but to no avail. I attempted to follow the Getting Started tutorial on Boost's website (for Unix Variants), but having problems along the way. I compiled the libraries into a directory in my Downloads folder: /Users/myUsername/Downloads/boostCompiled When I use the full path to the library .....

php regex - a href param

I have an X amount of hrefs that look like: <a href="http://url.com/?foo=bar&amp;p=20" title="foo">Foo</a><a href="http://url2.com/?foo=bar&amp;p=30" title="foo">Foo</a> I'm trying to extract the parameter p from each href found; So in this case have an end result array as: array (20, 30) What would be a good regex for this? Thanks ...

How do I store a list (or dict) of key terms from a regular expression? -Python

I am quite new at python and regex so please bear with me. I am trying to read in a file, match a particular name using a regex while ignoring the case, and store each time I find it. For example, if the file is composed of Bill bill biLl biLL, I need to store each variation in a dictionary or list. Current code: import re import sys im...

Matching non-whitespace in Java

I would like to detect strings that have non-whitespace characters in them. Right now I am trying: !Pattern.matches("\\*\\S\\*", city) But it doesn't seem to be working. Does anyone have any suggestions? I know I could trim the string and test to see if it equals the empty string, but I would rather do it this way ...

How can I quickly fix EBCDIC control characters in large files using Perl?

My apologies if this comes across as a newbie question. I'm not a Perl developer, but am trying to use it within an automation process, and I've hit a snag. The following command runs quickly (a few seconds) on my Linux system (Ubuntu 9.10 x64, Perl 5.10), but is extremely slow on a Windows system (Windows 2003 x86, Strawberry Perl 5.12...

Regex match in shell script

I'm writing a shell script that makes sure my DNS server is looking. Here's the output it tests: Server: 127.0.0.1 Address: 127.0.0.1#53 Name: galapagos.office Address: 192.168.140.25 Everything but the "galapagos.office" needs to match exactly. The "galapagos.office" part itself doesn't actually matter at all. I fi...

Removing whitespace-characters, except inside quotation marks in PHP?

Hey I couldn't find any similar question, so I start a new one. I need to remove all whitespace from string, but quotations should stay as they were. I'm building a personal kind of minifier. Here's an example: string to parse: hola hola "pepsi cola" yay output: holahola"pepsi cola"yay Any idea? I'm sure this can be done with rege...

NSCFArray length]: error, array regex

StringReply = [[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding]; //Regex Out Artist Name //NSString *regEx = ; NSArray *iTunesAristName = [stringReply componentsMatchedByRegex: @"(?<=artistname\":\")([^<]+)(?=\")"]; if ([iTunesAristName isEqual:@""]) { NSLog(@"So...

Efficiency of lookarounds in C# regular expressions. Should I avoid them if I can?

Hello, everyone! I'm quite new to regular expressions, but I like them, A LOT! Call me nitpicky if you will, but I'd really like to know if I should avoid using lookaheads and lookbehinds if I have an option. For example, the two commands below do the same thing, one uses lookbehind and the other doesn't. the_str = Regex.Replace(the_s...

Regex query with Google spreadsheet scripts

Hi, I'm trying to finish off a Google script to reformat a field that I would ideally like to turn into a hyperlink. This is the common format of the text in the spreadsheet: tistaff: other sections: person: randomname This is how I would like it to appear: <li><a href="http://www.thisisstaffordshire.co.uk/topics/person/randomname"&...

regex to get string within 2 strings

"artistName":"Travie McCoy", "collectionName":"Billionaire (feat. Bruno Mars) - Single", "trackName":"Billionaire (feat. Bruno Mars)", i wish to get the artist name so Travie McCoy from within that code using regex, please not i am using regexkitlite for the iphone sdk if this changes things. Thanks ...

How can i extract src attribut of embed tag

How can i extract src attribut of embed tag with regeex? in this exemple(youtube video): <object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/Ora35AzLxt0?fs=1&amp;amp;hl=fr_FR"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><e...

PostgreSQL Regex Word Boundaries?

Does PostgreSQL support \b? I'm trying \bAB\b but it doesn't match anything, whereas (\W|^)AB(\W|$) does. These 2 expressions are essentially the same, aren't they? ...

PHP url validation + detection

So here is what I need to do. If an user enters this: http://site.com I need to remove http:// so the string will be site.com , if an user enters http://www.site.com I need to remove http://www. or if the user enters www.site.com I need to remove www. or he can also enter site.com it will be good as well. I have a function here, but do...

Match regex that doesn't start with something

I have seen a few other similar questions, but I can't seem to get it to work. What I am trying to do is in JavaScript match a string with issue numbers. I have that part working fine, but I don't want to match it if it starts with target='_blank'>. These should match... Issue# 123 Issue #123 Issue 123 Issue no 123 Issue nu...

Django RegexField Letters and Numbers only

I need a regexfield in a django form to only accept letters and numbers, and nothing else. I've tried this, but it didn't work: myfield = forms.RegexField(label=("My Label"), max_length=31, regex=r'[a-zA-Z0-9]', error_message = ("This value must contain only letters and numbers."), I am not very good at using regular expressi...