regex

JS not accepting <> greater than or less than signs

I've been stuck on an interesting (IE: mind numbing) question for the past few hours. I've been trying to parse operators with regex: ([<>]=?|[!=]=) The ones that I want are: <= >= < > == != == and != matches great. But all the ones having to do with < or > doesn't on my Drupal site, even though they should theoretically work. What...

Maximum number of groups in Java Regex

I had assumed the maximum was 9 but after some experimentation I know it is not. The javadocs for Pattern and Matcher to not list a maximum. ...

RegEx - Matching a set of words

I've been on this one for a while and can't seem to work it out. Here's what I am trying to do. Given three words word1, word2 and word3, I would like to construct a regex which will match them in that order, but with a set of potential words between them (except a new line). For example, if I had the following: word1 = what word2 = ...

Need some regex help, please :)

Hi folks, i have the following regex pattern, which is used to strip out non, alpha-numerics. [^0-9A-Za-z] Works pretty good. I was hoping to mod this regex so it looks for alphanumerics AND spaces. How can i tweek it so it also accepts spaces? cheers :) ...

Is there a shorter way to pull groups out of a Powershell regex?

In PowerShell I find myself doing this kind of thing over and over again for matches: some-command | select-string '^(//[^#]*)' | %{some-other-command $_.matches[0].groups[1].value} So basically - run a command that generates lines of text, and for each line I want to run a command on a regex capture inside the line (if it matche...

Regular expression to transform 1.2.3 to 1.02.03

Hi guys, i'm really not good with regular expressions and i need one to transform "1.2.3" to "1.02.03" in a way that first part stays always as it was and second and third one will transform 2 to 02, 7 to 07 and so on but if there is 10, 15, 17 and so on it will leave it as it is. I want to use it in msbuild. samples: 2.5.7 -> 2.05....

Regex to replace hyphen in the middle of a word

Hi, I need a regex to replace hyphens in the middle of any word but not to touch leading or trailing ones or standalone ones. This is for use in .NET within Regex.Replace() I've tried the following \w[-]\w but that also captures the character either side of the hyphen. As an example, what I need is for the following string -test t...

java regex line

In java i would like to read a file line by line and print the line to the output. I want to solve this with regular expressions. while (...) { private static java.util.regex.Pattern line = java.util.regex.Pattern.compile(".*\\n"); System.out.print(scanner.next(line)); } The regex in the code is not correct, as i get InputMismatch...

Invert assignment direction in Visual Studio

I have a bunch of assignment operations in Visual Studio, and I want to reverse them: i.e i = j; would become j = i; i.e. replacing everything before the equals with what's after the equals, and vice versa Is there any easy way to do this, say something in the regular expression engine? Cheers, Ed ...

stripping street numbers from street addresses

Using Ruby (newb) and Regex, I'm trying to parse the street number from the street address. I'm not having trouble with the easy ones, but I need some help on: '6223 1/2 S FIGUEROA ST' ==> 'S FIGUEROA ST' Thanks for the help!! UPDATE(s): '6223 1/2 2ND ST' ==> '2ND ST' and from @pesto '221B Baker Street' ==> 'Baker Street' ...

What are the valid characters for Registry keys and valuenames?

More specifically, what is the authoritative source for that information? This may look like a non-programming question, but I need to know whether a registry path fed to my code contains a regular expression or not. I decided the best way to do that is assume that any occurrence of an invalid character (like '*') means a wildcard searc...

Stripping HTML Comments With PHP But Leaving Conditionals

I'm currently using PHP and a regular expression to strip out all HTML comments from a page. The script works well... a little too well. It strips out all comments including my conditional comments in the . Here's what I've got: <?php function callback($buffer) { return preg_replace('/<!--(.|\s)*?-->/', '', $buffer); } ...

How to get several regex groups from Matcher in Java?

I have a Java program that does some String matching. I'm looking for anything that matches \d+x\d+ in a String. This works, using the Pattern and Matcher classes. However, to parse the String parts I have found, I have to manually parse the String I get from the Matcher.find() and Matcher.group(). How can I tell the Pattern I'm looking ...

Powershell: Leave item alone if regex doesn't match

I have a list of pdf files (from daily processing), some with date stamps of various formatting, some without. Example: $f = @("testLtr06-09-02.pdf", "otherletter.pdf","WelcomeLtr043009.pdf") I am trying to remove the datestamp by stripping out dashes, then replacing any consecutive group of numbers (4 or more, I may change this to 6...

How to determine whether a string has regex metacharacters? (C#)

Does the System.Text.RegularExpressions namespace offer me anything to discover whether an input string has ("abc[0-9]" or "^aeiou$") or has not ("abc123") metacharacters? Or do I have to check manually for non-escaped characters in a certain list? ...

Reg Ex to match numbers and commas

I have a .csv file and I'm only interested in rows with comma delimeted integers: 23,2,4,56,78,9,4,6 The number of comma delimited values in a row should be more than 5 (or whatever). I'm doing this in perl. ...

Regular expression for pepper+tomato+watermelon

Regular expression for something+something+something ... +something? Sorry because of my great english and brain -> keyboard connection ...

Regex to match 2 digits, optional decimal, two digits

Hi, I've spent half an hour trying to get this, maybe someone can come up with it quickly. I need a regular expression that will match one or two digits, followed by an optional decmial point, followed by one or two digits. For example, it should match these strings in their entirety: 3 33 .3 .33 33.3 33.33 and NOT match a...

Regular Expression help

I have written code to pull some data into a data table and do some data re-formatting. I need some help splitting some text into appropriate columns. CASE 1 I have data formated like this that I need to split into 2 columns. ABCDEFGS 0298 MSD SDFKLJSDDSFWW 0298 RFD I need the text before the numbers in column 1 and the...

Regex-like syntax or CFG for generating cartesian product of concatenated string variables and literals

I am writing a simulator, and would like to run studies by invoking a lot of instances of the simulator, using different sets of command-line arguments. I have read this question and several others, and they seem close, but I'm actually not looking for random data fulfilling a particular regex, I would like the set of all strings that m...