regex

Youtube url tester with hyphens

Hi all, this is how i normally check for youtube url validity using javascript. It works great but fails for urls with "-" before the video id eg http://www.youtube.com/watch?v=-pIaQpwYEjY Any remedy available as I'm not well versed with regex var matches = $('#as_url').val().match(/^http:\/\/(?:www\.)?youtube.com\/watch\?(?=.*v=\w+)(?...

php, preg_match, regex, extract specific text

I have a very big .txt file with our clients order and I need to move it in a mysql database . However I don't know what kind of regex to use as the information is not very different . ----------------------- 4046904 KKKKKKKKKKK Laura Meyer MassMutual Life Insurance 153 Vadnais Street Chicopee, MA 01020 US 413-744-5452 lmeyer@massm...

JavaScript regular expression help

Hi, everyone. I've got a string looks like var s = "2qf/tqg4/ad(d=d,s(f)d)" And I've got another string var n = "abc = /fd/dsf/sdf/a.doc, " What I want to do is insert n after the first '(' So it will look like "2qf/tqg4/ad(abc = /fd/dsf/sdf/a.doc, d=d,s(f)d)" Thanks very much!!! ...

Python regular expression help

I've got a python string s = "Abc(problem=None, fds=5, sff=(2, 1, 0))" s2 = "Abc(problem=None)" What I want to do is remove the "problem=None, " So it'll looks like s = "Abc(fds=5, sff=(2, 1, 0))" s2 = "Abc()" Please mind the ',' How to achieve this? Thanks very much!! ...

Regex in preg_replace to detect url format and extract elements

I need to replace certain user-entered URLs with embedded flash objects...and I'm having trouble with a regex that I'm using to match the url...I think mainly because the URLs are SEO-friendly and therefore a bit more difficult to parse URL structure: http://www.site.com/item/item_title_that_can_include_1('_etc-32CHARACTERALPHANUMERICGU...

Javascript regular expression needed

Here is the format of the css I'm trying to edit using jquery. /*8d*/ .class{color:#444444;} /*5d*/ .class{background-color:#444444;} /*3f*/ .class{color:#444444;} /*9d*/ .class{color:#444444;} I want to replace several entire lines within using Regular Expressions. For example, How do I select line 5d the replace with "/*5d*/ .new{bo...

Out of curiosity, how many people here know how regular expressions are compiled?

I'm going over this in my theory class, and I'm curious as to how many people here know what regular expression compilation actually is. I've looked online, and it seems to me that this is a more archaic topic that I thought it was. So yeah, who here knew before reading this question that a regular expression compile is performed by co...

PHP ORM Mysql ordering using REGEX

You see I have a set of entries to be ordered alphabetically. Though some of the entries starts with "The". What I want is to ignore "The" and start sorting from the next word. For example: $titles->order_by("name", "ASC")->find_all() // Sample query Abraham Panorama The Malevolent What I want: Abraham The Malevolent // Ignore "t...

Regexp to check if an IP is valid

I'm wondering if it's possible to compare values in regexps with the regexp system in Python. Matching the pattern of an IP is easy, but each 1-3 digits cannot be above 255 and that's where I'm a bit stumped. ...

How can I get rid of $ prefixes in my variable names with jQuery?

I started off naming my jQuery objects like $this. Then, I decided I didn't want to do it anymore. I just borrowed a large chunk of code from an old project. It is from the $ prefix days, and it is irking me! What regex can I use in my IDE to get rid of the $ prefixes on my variables? ...

PHP regex periods

How do I put a period into a PHP regular expression? The way it is used in the code is: echo(preg_match("/\$\d{1,}\./", '$645.', $matches)); But apparently the period in that $645. doesn't get recognized. Requesting tips on how to make this work. ...

boost::regex and tilde (~)

Please could you explain why given the following boost::regex pattern: boost::regex re("/\\S+\\w"); /index.html is a match and /~index.html is not? RegexBuddy in Perl mode finds a match in both cases. Could you suggest a pattern that would work? Thanks!! P.S. The \\w at the end is needed in order to ignore the punctuation on the en...

How can I validate the range 1-99 using a regex?

Hi, I need to validate some user input, to ensure a number entered is in the range of 1-99 inclusive. These must be whole (Integer) values Preceeding 0 is permitted, but optional Valid values 1 01 10 99 09 Invalid values 0 007 100 10.5 010 So far I have the following regex that I've worked out : ^0?([1-9][0-9])$ This allows a...

RegEx with strange behaviour: matching String with back reference to allow escaping and single and double quotes

Hi, community. Matching a string that allows escaping is not that difficult. Look here: http://ad.hominem.org/log/2005/05/quoted_strings.php. For the sake of simplicity I chose the approach, where a string is divided into two "atoms": either a character that is "not a quote or backslash" or a backslash followed by any character. "(([^"...

Pattern match numbers/operators

Hey, I've been trying to figure out why this regular expression isn't matching correctly. List l_operators = Arrays.asList(Pattern.compile(" (\\d+)").split(rtString.trim())); The input string is "12+22+3" The output I get is -- [,+,+] There's a match at the beginning of the list which shouldn't be there? I really can't se...

How to grep directory for keyword existance?

For example I have a /path/to/folder and want to see if it contains "keyword1", "keyword2" or "keyword3" and the result would be (when 2 are found): /path/to/folder: keyword1 keyword3 I tried with options shown here but it doesn't work for folders. ...

Small remake of this regexp to allow these special character in beginning...

I have this regexp: var desExp = /^\s*([\wåäö][^\w]*){3}.*$/gm; This is for validating a textarea. Currently, you cant use the three Swedish language letters in the beginning. The letters are å, ä, ö, Å, Ä, Ö. Also, I would like it to allow the minus sign and the star (multiplication) sign: - and * Is there any remake to allow ...

How can I remove a specific character from a string in Perl?

I'm trying to remove a specific character from a string in Perl: my $string="MATTHATBAT"; substr($string, 2, 1, ''); EDIT: This does work, sorry. Leaving this here in case someone needs to know how to do this. Also, is there a more efficient way of doing this? The string should now be MATHATBAT. Am I missing something? I know tha...

Phone number regular expression for UK and US phones

Hi, Has anyone got a good regex that will match on both UK and USA numbers? It would need to cater for uk prefixes like +44 and also the US equivalent. Does anyone know of such an expression? Cheers Paul ...

Help with regex for commas in sql query

Hi, I have a SQL query like: select column1 as a, DECODE(x, 1, x1, 2, x2) as column2, DECODE(y, 1, y1, 2, y2) as column3 from test And I want to select the following commas (denoted with **,**): select a as column1 **,** DECODE(x, 1, x1, 2, x2) as column2 **,** DECODE(y, 1, y1, 2, y2) as column3 from test I am using /(?!(...