regex

.NET RegEx to validate password between 6 and 20 characters with at least one upper case letter, one lower case letter and one digit

I need a regex to validate passwords with the following specs: It must be between 6 and 20 characters with at least one upper case letter, one lower case letter and one digit ...

find duplicate lines and remove using regular expression with replace feature

Not use any programming language. Only use regular expression. is it possible? For example input>> 11 22 22 <-must remove 33 44 44 <-must remove 55 Output>> 11 22 33 44 55 ...

How can I make a regex to find instances of the word Project not in square brackets?

For example: $lang['Select Project'] = 'Select Project OK'; $lang['Project'] = 'Project'; I want to find only the instances of the word 'Project' not contained within the square brackets. I'm using cold fusion studio's extended replace utility to do a global replace. Any suggestions? Code Sample Follows: <?php $lang['Project...

Extract filename from HTML text using regexp

I have this HTML code (just an example): Sem vestibulum blandit nostra, nullam imperdiet, pellentesque vel wisi sit fusce purus mi, porttitor lorem. Bibendum non phasellus ut ipsum massa sed, interdum per, facilisis facilis luctus fermentum et donec, tristique tristique non.</p> <p align="justify"><a class="nemo" href="http://myserver.c...

Regular expression to find instances of strings within XML nodes

I need to find all instances of strings within an xml node. To be more specific, I'd like to parse some XAML and place all strings within certain controls (label for one) and set them as attributes instead. So, instead of this <Label>My string</Label> I want this: <Label Content="My string"></Label> The regular expression I have ...

Single dash phone number - regex validation

I need a simple regex to validate a phone number of the form x-y, where x and y can represent any number of digits and the dash is optional, but if it does show up it most be within the string (the dash must have digits at its left and right) ...

Regexp character filter

In my code, I use a regexp I googled somewhere, but I don't understand it. :) preg_match("/^[\p{L} 0-9\-]{4,25}$/", $login)) What does that p{L} mean? I know what it does -- all characters with national letters included. And my second question, I want to sanitize user input for ingame chat, so I'm starting with the regexp mentioned ...

How to obtain matched subexpression from a Regex match? (C#)

Let's say I'm matching with a pattern that has subexpressions like this: Regex myRegex = new Regex("(man|woman|couple) seeking (man|woman|couple|aardvark)"); string myStraightText = "Type is man seeking woman, age is 44"; MatchCollection myStraightMatches = myRegex.Matches(myStraightText); string myGayText = "Type is man seeking man, ...

Regex for Nested BBCode

I'm trying to create a regex that will capture BB Codes, BB Codes with extra parameters ([url=http://]url[/url]) etc. and work properly with nested BB Codes. I would then recursively parse the BB Codes starting with the inner most. This is what I have so far, but it breaks when I try to match nested BB Code. Pattern: \[(.*)\b=?([^=]...

Regex: Remove empty-element tags for xml

I'd like to replace all self-closed elements to the long syntax (because my web-browser is tripping on them). Example <iframe src="http://example.com/thing"/&gt; becomes <iframe src="http://example.com/thing"&gt;&lt;/iframe&gt; I'm using python's flavor of regex. ...

help with getElementsByTagName setAttribute and regex javascript

i want to put rel=lightbox to some links that mediabox support using javascript. i try this and wonder why it's not working? test: http://jsbin.com/opica please help edit this: http://jsbin.com/opica/edit <script type="text/javascript"> var x=xmlDoc.getElementsByTagName("a"); var regexku=/^.+(((twit)|(tweet)|(com/video.+)|(flickr.c...

In regex, what does \w* mean?

In Python. r^[\w*]$ whats that mean? ...

How to use ? and ?: and : in REGEX for Python?

I understand that * = "zero or more" ? = "zero or more" ...what's the difference? Also, ?: << my book uses this, it says its a "subtlety" but I don't know what exactly these do! ...

How to take only first line from the multiline text

How can I get only the first line of multiline text using regular expressions? string test = @"just take this first line even there is some more lines here"; Match m = Regex.Match(test, "^", RegexOptions.Multiline); if (m.Success) Console.Write(m.Groups[0].Value); ...

Regular Expression in Notepad++ (Ignore if contains)

Hi I'm a newbie I am trying to create a regex in notepad ++ to replace all href="http://www.reactivemail.com/(any series of charcters)" essentially all I want is to put a / on the end of all href's but only if it does not contain a dot e.g it is a path to a file like .html so here is what i want to find href="http://www.reactivemail.c...

PHP regex to limit new lines to a maxmium of two

I'm using this but it's replacing single occurances of a new line with <br/><br/> function nl2br2($string){ $string = preg_replace('/(\r\n){2,}/', '<br/><br/>', $string); //$string = preg_replace('/[\r\n]/', '<br/>', $string); return $string; } It happens with the first pattern. ...

Will this regex be enough to remove C++ multiline comments?

I need to parse some C++ files, and to make things easier for me, I thought about removing multiline comments. I tried the following regex : /(\/\*.*?\*\/)/, using the multiline modifier, and it seems to work. Do you think there will be any case where it will fail? ...

Is there a regular expression for a comma separated list of discrete values?

I use the following regular expression to validate a comma separated list of values. ^Dog|Cat|Bird|Mouse(, (Dog|Cat|Bird|Mouse))*$ The values are also listed in a drop down list in Excel cell validation, so the user can select a single value from the drop down list, or type in multiple values separated by commas. The regular expressi...

PHP Regex remove unwanted data

Hi All I would like to be able to remove content from a string of data. This is an example string from google maps api. Distance: 70.5&#160;mi (about 1 hour 12 mins)<br/>Map data &#169;2009 Google I would like everything in between the brackets (). So can I remove everything from either side with preg_split ? Hope you can advise. ...

Java: How to replace all occurances of a character if and only if followed by some other character

In particular: I want to replace all occurances of a full stop \. with a full stop plus white space \.\s if the full stop is immediately followed by an upper case character [A-Z]. Any suggestions? thanks ...