regex

.Net RegularExpressionValidator matches differently than Regex class

Hello all, When I use the .Net RegularExpressionsValidator control the Validation expression matches EXACT text. When I say this I mean, for the string I give it to validate, if it deviates from the regex pattern at all the string does not validate. ex: (([0-1][0-9])|([2][0-3])):([0-5][0-9]) if given in the RegularExpressionsValidator...

What regular expression will match a pattern or be empty?

I need regular expression that matches a pattern or is empty. Right now I have an expression... "\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x" ... which matches US phone numbers. However, it is valid for the string I'm testing to be empty. If the string has any value in it at all, it must match the expression. I have other patterns which ...

Is there a decent Vim regexp OR command? What is the best way to find mismatched if else's?

I have some mismatching if and fi statements in a script. I would like to strip out everything but the if's else's and fi's. Just so I can see the structure. Why am working so HARD with such a powerful editor? I need a BIGFATOR operator for regexp or some epiphany that has eluded me... I don't care for pontification on regular expres...

concatenate multiple regexes into one regex

For a text file, I want to match to the string that starts with "BEAM" and "FILE PATH". I would have used ^BEAM.*$ ^FILE PATH.*$ if I were to match them separately. But now I have to concatenate those two matching patterns into one pattern. Any idea on how to do this? ...

C# Regex sorting letter and number strings

I have a list that needs ordering say: R1-1 R1-11 R2-2 R1-2 this needs to be ordered: R1-1 R1-2 R1-11 R2-2 Currently I am using the C# Regex.Replace method and adding a 0 before the occurance of single numbers at the end of a string with something like: Regex.Replace(inString,@"([1-9]$)", @"0$2") I'm sure there is a nicer way to...

RegEx Numeric Check

Hi! I'm new to StackOverflow, so please let me know if there is a better way to ask the following question. I need to create a regular expression that detects whether a field in the database is numeric, and if it is numeric does it fall within a valid range (i.e. 1-50). I've tried [1-50], which works except for the instances where a s...

Regular expression match only if subpattern doesn't match

Hello I'm trying to match C style comments form a file, but only if the comment don't start with a certain labels introduced by @ For example from /* some comment to match */ /* another comment. this should match also */ /*@special shouldn't match*/ Is this possible using regular expressions only? I'm trying this using JavaScript i...

Regex not returning 2 groups

Hello everyone, I'm having a bit of trouble with my regex and was wondering if anyone could please shed some light on what to do. Basically, I have this Regex: \[(link='\d+') (type='\w+')](.*|)\[/link] For example, when I pass it the string: [link='8' type='gig']Blur[/link] are playing [link='19' type='venue']Hyde Park[/link]" ...

Backreference in Regular Expression Quantifier

I have a string that contains a header with a length of the following field. Example: fillerfillerCA20 abcdefghijklmnopqrst CA5 zyxwvfillerfiller I need to find the two values: abcdefghijklmnopqrst and zyxwv I was going to use a backreference to get the length for the quantifier: (?i)ca(?<length>\d+?)\x20.{\k<length>}\x20? but ap...

Why is my RegExp construction not accepted by JavaScript?

I'm using a RegExp to validate some user input on an ASP.NET web page. It's meant to enforce the construction of a password (i.e. between 8 and 20 long, at least one upper case character, at least one lower case character, at least one number, at least one of the characters #@!$% and no use of letters L or O (upper or lower) or numbers 0...

Splitting out the output of ps using Python

On Linux, the command ps aux outputs a list of processes with multiple columns for each stat. e.g. USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND ... postfix 22611 0.0 0.2 54136 2544 ? S 15:26 0:00 pickup -l -t fifo -u apache 22920 0.0 1.5 198340 16588 ? S 09:58 0:05 /usr/sbin/h...

PHP: Parse a string to perform replacements

I have a group of text based rules that are structured like this: Rule 1: Do [XXX] when [PN] greater than [N] Rule 2: Get [PRD ..] and add [X.XX] To go with this is an array of data that translates each grouped code into a CSS class ID (for jQuery). I also have an array of translations from [code] to ID stored in a simple structured...

Unix - substitution

Hi, i have problem with substitution. I have a file with 1 line of random characters with brackets "{}" around 1 character. I want to move with these brackets on the previous character or on the next one. (I know how to do it if the line of character is still, non-changing.) But I wonder how to do it when I don't know these chars and I d...

Filter or remove item.description from an RSS feed

I would like to remove the item.description part of a twitter feed within yahoo pipes and I haven't figured out how to do it yet. Obviously the filter module will remove posts with that item so I've been trying to use Regex. I think clearing the item.description field would work well enough. Is there a Regex expression that would repla...

Using escape characters inside grep

I have the following regular expression for eliminating spaces, tabs, and new lines: [^ \n\t] However, I want to expand this for certain additional characters, such as > and <. I tried [^ \n\t<>], which works well for now, but I want the expression to not match if the < or > is preceded by a \. I tried [^ \n\t[^\]<[^\]>], but this did...

Multiple captures with one set of parens in a larger regex

I've got a regular expression (javascript) which is something like... /(x)(y)+(z)/gi The problem is that I'll always get exactly 3 captures from those parens, even if the (y)+ matched multiple times. If it does match multiple times, it just returns the last match. I've no way of knowing ahead of time how many times y will match on any ...

Strange .NET Regex Issue

Given the following RegEx expression, testing this on regexlib.com with the string "2rocks" produces a 'match'. However, in my .NET application, it's causing the regex validator to throw a validation error. ^(?=.*[A-Za-z])[a-zA-Z0-9@\-_\+\.]{6,32}$ If I change the string to "rocks2" in both my application and regexlib.com, I get a mat...

Regular expression extraction in text editors...

I'm kind of new to programming, so forgive me if this is terribly obvious (which would be welcome news). I do a fair amount of PHP development in my free time using pregmatch and writing most of my expressions using the free (open source?) Regex Tester. However frequently I find myself wanting to simply quickly extract something and th...

Regular Expression (Java)

How do I match the following string? http://localhost:8080/MenuTest/index.action The regex should return true if it contains "MenuTest" in the above pattern. Cheers ...

How to check an UTC formatted date with a regular expression?

As you know the format is like: "YYYY-MM-DDTHH:NN:SS.ZZZ+XX:XX" (i.e. "2009-03-24T16:24:32.057+01:00") I have to do it in a ActionScript3 class but any source will be appreciated, thanks. ...