regex

one line match in JS regex

What is the JavaScript equivalent of this .NET code? var b = Regex.IsMatch(txt, pattern); ...

jQuery use .live with jquery-keyfilter plugin

I am using jquery-keyfilter plugin to mask textbox inputs. However the textboxes are added to the page dynamically and I cannot figure out how to apply the key filter to them. I have tried $('#myelement').live('keyfilter', myFunction ); Also $('#myelement').live('keyfilter', /regex/); Kai: comment helps, but it seems my problem is...

In regex is it called lazy or non-greedy?

I originally heard it as nongreedy. Then on references 'on the web' i saw it called as lazy. Which is it? ...

error /usr/local/bin/perl: Argument list too long

Hello guys ive executed this command to delete malwarm from all my websites files and keep backup from each files but after 1 mint from executing got error /usr/local/bin/perl: Argument list too long Can anyone suggest a way to avoid this error , PS ive a huge a mount of files :) perl -e "s/<script.*PaBUTyjaZYg.*script>//g;" -pi.sa...

count all HTML tags in page PHP

I spent time on regex to solve this problem but not have result i try solve this problem using PHP 5.3 Information like - How many times repeats in page - How many times repeats in page and information about all tags in page ...

regex to match <Key>....<Value> pattern

I have the following data sent by an external system which needs to be parsed for a particular Key <ContextDetails> <Context><Key>ID</Key><Value>100</Value></Context> <Context><Key>Name</Key><Value>MyName</Value></Context> </ContextDetails> I tried parsing this with the regex to fetch the value for the KEY : Name <Context><Key>Name<...

.NET regular expression

I have html page source code with img tags like <p>xyz </p>< img ....... 1 . gif >........<p>xyz</p> < img ........ 2 . jpg >..............<p>xyz</p> < img ........ 3 . jpg ><p>xyz</p> < img ....... 4 . gif >......<span>xyz</span> Img tags can contains both jpg and other format images and can be i...

Complex-ish regex problem

I need to parse out writeln("test"); from a string. I was using (?<type>writeln)\((?<args>[^\)]*)\); as the regex, but this isn't perfect, if you try and parse writeln("heloo :)"); or something similar, the regex won't parse it (because of the ')' in the quotes). Is there a way to register that since the ')' is in the quote marks, the r...

Rails regex for validation of Google Maps latitude longitude

Hi guys, I'm trying to do a validates_format_of on the latlng object that is passed back from Google Maps API. I've got the map set up perfectly so that when I click on a point in the map it fills in a text-field with the latlng (which looks like this: 46.320615137905904, 9.400520324707031). I'm storing this value as a string in the db ...

`regex{n,}?` == `regex{n}` ?

-edit- NOTE the ? at the end of .{2,}? I found out you can write .{2,}? Isnt that exactly the same as below? .{2} ...

Regex validity for Degree

hi all, i have an assignment where i should check validity of the string where : N90 -> North and must have key degree between 0-90 W180 -> have degree between 91-180 S270 -> have degree between 181-270 E360 -> have degree between 271-360 how can i create a reg ex like this. ...

Regular expression Help!

I want to metch a keyword that is not linked, as the following example shows, I just match the google keyword that is neither between <a></a> nor included in the attributes, I only want to match the last google: <a href="http://www.google.com" title="google">google</a> is linked, google is not linked. ...

Why doesn't this pattern work in egrep?

Why can't I match the string "1234567-1234567890" with the given regular expression \d{7}-\d{10} with egrep from the shell like this: egrep \d{7}-\d{10} file ? ...

regular expression - incremental replacement

Hi All, Is there any way to do integer incremental replacement only with regex. Here is the problem, I have text file containing 1 000 000 lines all starting with % I would like to have replace # by integer incrementally using regex. input: % line one % line two % line three ... output: 1 line one 2 line two 3 line three .....

how to validate US currency with this format $123.45

Hi I have one one web page which one one textbox for receiving the dollar value. My requirement is the user should insert the digit following by a $ sysmbol. And the second requirement is the user has the permission to insert only like this $123.45. Before the decimal point it should not exceed three digits and after the decimal point it...

Extracting username from UNIX path using Regex

Hi! I need to get a username from an Unix path with this format: /home/users/myusername/project/number/files I just want "myusername" I've been trying for almost a hour and I'm completely clueless. Any idea? Thanks! ...

Regular expressions in java with a variable

I have a variable v that possibly appears more than one time consecutively in a string. I want to make it so that all consecutive *v*s turn into just one v. For example: String s = "Hello, world!"; String v = "l"; The regex would turn "Hello, world!" into "Helo, world!" So I want to do something like s = s.replaceAll(vv+, v) But o...

Grep and regex: inconsistent behaviour

Hi all, I was working on the Linux box A and I run this: grep '^\S*\s-' access_log That displayed some lines, as expected. Then I moved to the machine B and I launched exactly the same command. But this time it didn't work. I had to launch this in order to get done what I needed: grep '^[^ ]* -' access_log Before succeeding, I...

Replace using RegEx outside of text markers

I have the following sample text and I want to replace '[core].' with something else but I only want to replace it when it is not between text markers ' (SQL): PRINT 'The result of [core].[dbo].[FunctionX]' + [core].[dbo].[FunctionX] + '.' EXECUTE [core].[dbo].[FunctionX] The Result shoud be: PRINT 'The result of [core].[d...

Python regular expression style

Is there a Pythonic 'standard' for how regular expressions should be used? What I typically do is perform a bunch of re.compile statements at the top of my module and store the objects in global variables... then later on use them within my functions and classes. I could define the regexs within the functions I would be using them, but...