regex

regular expressions date

I'm working in javascript and I need to figure out how to determine a valid date using regular expressions matches will be: dd-mm-yyyy dd-mm-yy Also no leading zeros should be accepted like: 9-8-2010 10-6-99 Can anyone help me out with this? ...

REGEX a word in a paragraph, but not a word containing that word, unless its a plural.

I am highlighting words in a body of text. If I regex "Port" the word "Portuguese" is highlighted too, but I need "Ports" to be highlighted. Any ideas? I hate regex. Thanks ...

Regular Expression performance issue to pasrse big contents

Suppose i have to filter some text from a file. Then i have 2 solutions Either I take all the contents of file into a single variable(like fileinputstream or something else) which can be parsed using regular expression. Or i use looping to read file line by line. Then i apply either regular expression or some string function on each li...

Parsing facebook oauth access_token string

Facebook returns access tokens in the form of a string: 'access_token=159565124071460|2.D98PLonBwOyYWlLMhMyNqA__.3600.1286373600-517705339|bFRH8d2SAeV-PpPUhbRkahcERfw&expires=4375' Is there a way to parse the access_token without using regex? I'm afraid using regex would be unaccurate since I don't know what FB uses as access tokens...

Regex help required

I am trying to replace two or more occurences of <br/> (like <br/><br/><br/>) tags together with two <br/><br/> with the following pattern Pattern brTagPattern = Pattern.compile("(<\\s*br\\s*/\\s*>\\s*){2,}", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); But there are some cases where '<br/> <br/>' tags come with a space and they ...

how do i check all the lines in a textarea should not contain "<script>"

I am having a text like this this is my sample \n text message \n for validation i want a single REGEX to find whether that message contains a particular word ...

IIS URL Rewrite rule help?

I am using the IIS7 URL Rewrite module. I want to create a rule that matches this: http://www.mydomain.com/test123. but not this: http://www.mydomain.com/test123/ Any help is much appreciated. Also any links to examples of common rewrite regex would be a plus ...

How can I replace the same string several times with different random values in Perl?

I'm using this Perl one-liner (in bash) to successfully replace a string with a random one, in a given file: perl -pi -e "s/replace\ this/`</dev/urandom tr -dc A-Za-z0-9 | head -c64`/g" example.php However, I don't know how to replace several "replace this" with different random strings. ...

Regex help required - V2 formatted

Possible Duplicate: Regex help required I am trying to replace two or more occurences of <br/> (like <br/><br/><br/>)tags together with two <br/><br/> with the following pattern Pattern brTagPattern = Pattern.compile("(<\\s*br\\s*/\\s*>\\s*){2,}", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); But there are some cases wher...

Is there a way to extract submatches from a regular expression in MySQL?

I am aware of the existence of the RLIKE and REGEX operators, but it seems like they cannot be used for that. Is there a function or an operator that would help me achieve splitting a text field and selecting it as two or more separate fields: SELECT $1 as `field_a`, $2 as `field_b` FROM `table` WHERE `field` RLIKE '^(.+):(.+)$'; I a...

C# Regex matches aabbccddeeff as two aabbcc and ddeeff sets

When I do this: var m = Regex.Match("aabbccddeeff", "[0-9a-fA-F]{6}"); I get only aabbcc as result. Actually (using .Matches) there're two matches: aabbcc and ddeeff. Why? This causes issues with DataAnnotations.RegularExpressionAttribute because it expects single match that covers whole input value. How do I write this properly to ...

Help me optimize a regular expression

Help me optimize a regular expression <form id='myForm'> Enter phone number:<input type="text" id='idMyText' name="myText" onKeyUp="alphaToNum(this.value)"> </form> <script> // on each keypress in input box, I want to capture key pressed, // determine if key pressed belong to group of identified characters // if, so then convert to sp...

Regular expression to match a certain HTML element

I'm trying to write a regular expression for matching the following HTML. <span class="hidden_text">Some text here.</span> I'm struggling to write out the condition to match it and have tried the following, but in some cases it selects everything after the span as well. $condition = "/<span class=\"hidden_text\">(.*)<\/span>/"; If ...

Regular expression to remove the last column from a pipe delimited file.

I've got a file with 1000's of entries and 131 columns, the columns are pipe delimited. There is no pipe at the end so format is something like. 2010-10-04|Security|AMEND|20162214| ... lots more columns ... |Bloomberg How can I remove the last column of the file say in Vim ? ...

Replace characters

I have a lot of strings of special characters. I want to replace all special characters with character "-" The characters do not need to be replaced as "-" are "A-Za-z0-9" ...

python regular expressions

hi i have a string like this track._Event('product', 'test');Product.lisen(1234, 21, 4343); return false; i want to use some regular expression so i would end up with groups pid = 1234 p1 = 21 p2 = 4343 ...

Mercurial ignore part of a directory

Been fighting with Mercurial's .hgignore for a while under Windows. I have a folder named Upload which is currently empty. I do want it tracked so I added a .empty file in it which work fine. I want this so that new developers doing an hg clone get the Upload document required for the application. Thing is I never want the folder to ...

Searching for particular word in files.

Hi All, We have a requirement to replace word 'ABC'(dummied) with 'XYZ'(dummied) in all the files. We have hundreds of aspx/ascx/cs/xml/xsl files which might contain the word. The requirement is Do not replace word if it is part of NameSpace(eg ABC.A1.A2 should not be replaced) or variable names(var abc = "") or tags (abc:control)....

Regex Problem in Java

I am working on some regex and I wonder why this regex "(?<=(.*?id(( *)=)\\s[\"\']))g" does not match the string <input id = "g" /> in java?? Thanks ...

Reverse regular expression search

I have a string which contains "foo"s followed by numbers. I'm looking to print the number following the last foo in the string. I've been told that the only way to accomplish this is to reverse the string itself. This isn't very elegant, and I'm surprised Perl doesn't have a better way to get the job done. Is there a better way to do it...