regex

JavaScript/Jquery RegEx to validate an EMAIL Address isn't working correctly.

I'm using the following lines of JavaScript to validate an input as a valid email address: // Check for a valid email address var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; var address = $('#formRegister-emailAddress').val(); if(reg.test(address) == false) { // Validation Failed alert('Please enter a va...

Apply regular expression substitution globally to many files with a script

I want to apply a certain regular expression substitution globally to about 40 Javascript files in and under a directory. I'm a vim user, but doing this by hand can be tedious and error-prone, so I'd like to automate it with a script. I tried sed, but handling more than one line at a time is awkward, especially if there is no limit t...

How to edit "Full Windows Folder Path Regular Expression".

Hay this regualr expression working fine for Full Windows Folder Path ^([A-Za-z]:|\\{2}([-\w]+|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\\(([^"*/:?|<>\\,;[\]+=.\x00-\x20]|\.[.\x20]*[^"*/:?|<>\\,;[\]+=.\x00-\x20])([^"*/:?|<>\\,;[\]+=\x00-\x1F]*[^"*/:?|<>\\,;[\]+=\x00-\x20])?))\\([^"*/:?|<>\\.\x0...

python regular expression

hi, well this is my problem, i'm working in a script (python) to find some files, i compare names of files against a regular expression pattern, now, i have to find files ended with a "~" (tilde), so i builded the next regex: if re.match("~$", string_test): print "ok!" well, python seems to not recognize the regex, i dont know why...

what's a flavor in regex world and which Java use

I'm not a native English and so I don't understand well the meaning of 'flavor' may be is it referred to a regex syntax?? and if so how many regex syntax are there? BRE ERE Perl etc.?? ...

Regex: matching all improper tag attributes

For an example input of: <a href="abc" something=b foo="bar" baz=cool> I am trying to match: something=b baz=cool However, everything I end up with will only match the first one (something=b), even when using preg_match_all. The regular expression I am using is: <\w+.*?(\w+=[^"|^'|^>]).*?> Or: <\w+ # Word starting with < .*? #...

Why does changing this regex class to .+ not provide any match?

If I use this string showPattern = @"return new_lightox\(this\);"">[a-zA-Z0-9(\s),!\?\-:'&%]+</a>"; MatchCollection showMatches = Regex.Matches(pageSource, showPattern); I get some matches but I want to get rid of [a-zA-Z0-9(\s),!\?\-:'&%]+and use any char .+ but if do this I get no match at all. What am I doing wrong? ...

How to prepare Email Validation test case?

HI , I am writing a java program to validate email addresses. This program use Pattern class to validate the input string against the Regex pattern. I have procured Regex Pattern for the email validatation and my program is successfully working. Now, I see some wrong email addresses in my database(Email delevery fails to these addresse...

Check if specific chars were written and trigger an error

Hi, Im trying to figure out via JS if invalid chars were entered in a textarea I want to allow only this chars: A-Za-z0-9 !#%&*()+-=,.?"';:/ If illegal chars were entered, I want to retrieve the bad chars, and trigger an error, i.e: Invalid text, bad chars were written: 1) _ 2) @ etc... Thanks! ...

Ruby parsing HTML for CSS files

Hi, I am working with some HTML for my site, I am basically moving my site from PHP to Rails. I have literally thousands of pages and some parts of the site have different CSS files from others. I can grab the tags fine but I added some conditions for different stylesheets to be loaded if its IE6/IE7/IE8 etc. I am trying to figure o...

function to return regular expression matches in mysql like preg_match return array in php

Hi, I've table with data like ticketid | comments ---------------------- 1234 | > > Ticket ID:TT19027 > > Ticket Title:report debug > > 4567 |> > Ticket ID:TT19028 > > Ticket Title:report debug > > I'm looking for a function or query that will return ticketid | ticket_no_part_of_comments 1234 | TT19027 4567 ...

Regular expression help

Hi all, I'm trying to extract functions and function headers from some source code files. Here's an example of the type of code: ################################################################################ # test module # # Description : Test module # DATABASE test ### # Global Vars GLOBALS DEFINE G_test_string STRING END G...

Find a tag with a specific suffix using preg_match

I'm looking for tags that end in a specific way using regular expressions in PHP. However all my attempts either result in too much or too little. For example, in the following string I'd like to match 'bar' because it is in a tag that ends with 'suffix'. preg_match_all("/<(.*?)suffix>/", "<foo> <barsuffix> <baz>" However the above l...

Regular expression regex help; ignore random blocks of data

Hello, I am doing a regex search on binary files, and I've just discovered a problem, every so often, a 64 byte checksum is used, which throws my searches out. What I want to know is; is there a way to ignore these 64bytes, regardless of where they appear in my data? My regex is \x18\xC0\x40[\x42\x43][\x00\x01]\x00\x00\x00 my prob...

making sure string contains no digits using regex in ruby?

HI how can i ensure that a string contains no digits using regex in ruby? thanks ...

perl pattern match Downloaded: 1 files, 8.7K in 0s (16.9 MB/s)

I have the following string "Downloaded: 1 files, 8.7K in 0s (16.9 MB/s)" which I got from wget and want to pattern match it by making a regular expression of it. I tried with: /^Downloaded: ([0-9]*) files, ([0-9GK]*) in ([0-9.]*)s ([0-9.]) [KM]B\/s/ But it does not work. I would appreciate any help. Thanks! ...

Regular expression for a specific pair or each item in a pair

I have a situation where I might be getting one or both of a pair of characters and I want to match either. For example: str = 'cddd a dfsdf b sdfg ab uyeroi' I want to match any "a" or "b" or "ab". If the "ab" comes together I want to catch it as a single match (not as two matches "a" "b"). If I get "ab" it will always be in that or...

Regexp matching attributes for html element

Hi, I'm working on a regular expression pattern to extract tag and attributes from an html element. But I have some problems with matching the attributes :s. Only the last attribute is stored into the matches array. Here is the code: <?php $subject = '<font face="arial" size="1" color="red">hello world!</font>'; $find= '/<(?P<...

grep regex : extract pattern from all files in a directory

Lets say a directory has two files. Here are the contents File1.txt tagstart random string tagend tagstart random string tagend File2.txt tagstart random string tagend tagstart random string tagend I want to grep the directory and extract the lines that have the following pattern tagstart <any string> tagend I also want to pi...

CSV to MYSQL parse issue

I am trying to parse a .csv file into a mysql database, and it's not fun. Some rows look like this: "Value", Value, "Value3", ,"Value,Value" And some look like this: Value, Value, , Value, , Value This preg_split worked well except for fields that were empty: foreach ($row as $item) { $item = preg_split( "/[,]*\\\"([^\\\"]+)\\...