regex

Java Regex that only replaces multiple whitepaces with Non-Breaking Spaces

I am looking for a Java regex way of replacing multiple spaces with non-breaking spaces. Two or more whitespaces should be replaced with the same number of non-breaking spaces, but single whitespaces should NOT be replaced. This needs to work for any number of whitespaces. And the first characters could be 1 or more whitespaces. So i...

Parsing StarTeam command line client output

I'm trying to write a Perl script that will parse the output of the stcmd.exe (the StarTeam command line client) hist command. I'm getting the history for every file in a view and the output looks something like this: Folder: The View Name (working dir: C:\Projects\dir) History for: main.h Description: Some files Locked by: Status: Cur...

regex to convert find instances a single \

I am looking to replace \n with \\n but so far my regex attempts are not working (Really it is any \ by itself, \n just happens to be the use case I have in the data). What I need is something along the lines of: any-non-\ followed by \ followed by any-non-\ Ultimately I'll be passing the regex to java.lang.String.replaceAll so a reg...

Matching nested [quote] in using RegExp.

I'm trying to get regexp to match some nested tags. (Yes I know I should use a parser, but my input will be correct). Example: Text. More text. [quote] First quote [quote] Nested second quote. [/quote] [/quote] Let's say I want the regexp to simply change the tags to <blockquote>: Text. More text. <blockquote> First quote <blockquot...

how to extract address from a text using regex in Ruby

I am trying to extract a US address from a text. So if I have the following variations of text then I'd like to extract the address portion Today is a good day to meet up at a bar. the address is 123 fake street, NY, 23423-3423 just came from 423 Elm Street, kk, 34223 ...had awesome time blah blah bleh blah 23414 Fake Te...

Matching with Opening/Closing Pair Characters in Regular Expressions

First, a little background. I have strings that resemble the following: ((Foo.Bar.StartsWith("A")) && (Foo.Bar.EndsWith("B"))) And I'm trying to reformat these to look like this: ((Foo.Any(Bar.StartsWith("A"))) && (Foo.Any(Bar.EndsWith("B")))) Side Note: The parts following the .Bar may sometimes not include (), like .Bar...

Javascript regular expression

string = 'Hello _1234_ world _4567_'; string.match(/(\d*)/gi); //,,,,,,,1234,,,,,,,,,,4567,, If I change regext to have \d+ then I get proper values: 1234 and 4567. Why in the first case I am getting all those empty matches. ...

Javascript regular expression

string = 'Hello 1234_ world 4567_ trap 456'; I need to capture all digits followed by underscore. Following code will do. string.match(/(\d+?)(_)/gi); However I tested following code and it worked except that underscore was also being captured. (\d+)_ So I decided to give underscore its own capture group like this (\d+)(_) But ...

Remove special characters in string with Regexp- jQuery

Who can help me with regular expression , to remove some string with jquery, don't have much experience in regex <div class="test" > &nbsp;&gt;&nbsp;&nbsp;&gt;&nbsp;Test Text </div> I want to remove "&nbsp;&gt;&nbsp;&nbsp;&gt;&nbsp;" and to leave just the text Thanks!! ...

Perl Regex Grammar For ANTLR Use

I need to create a regex parser for a project and I am using ANTLR v3 to do this. I am trying to find an up-to-date, Perl6-like regex grammar. Does anyone have a source? Googling for this has been difficult for some reason. ...

Regexp to parse out a person's name?

This might be a hard one (if not impossible), but can anyone think of a regular expression that will find a person's name, in say, a resume? I know this won't be 100% accurate, but I can't come up with something. Let's assume the name only shows up once in the document. ...

Regular Expression to test for the number of any characters in a range

I'm using the ASP Validation control a wanted to test that multiline textbox content was between 2 and 40 characters. Any character can be provided, including the new line character. What would be the expression? What I have below fails. <asp:RegularExpressionValidator ID="RegularExpressionValidator" runat="server" ValidationExpr...

Regex redefinition error

I am using python, and run into some redefinition error, I know they are redefinition but logically its not possible to reach that since its an or. Is there a way to get around this? I appreciate for any help in advance /python-2.5/lib/python2.5/re.py", line 233, in _compile raise error, v # invalid expression sre_constants.error: r...

jQuery: create regex pattern from variable

hi all, i'm trying to create a regex pattern out of a variable like: var tag = "style"; var pattern = "/<"+tag+"[^>]*>((\\n|.)*)<\\/"+tag+">/gi"; but it won't work - anyone can tell me what's wrong? thx ...

Regular Expression to Match " | "

Hey guys, I am trying to use Java's useDelimiter method on it's Scanner class to do some simple parsing. Basically each line is a record delimited by " | ", so for example: 2 | John Doe 3 | Jane Doe 4 | Jackie Chan The method takes as a parameter a regular expression for which to match for. Can someone please provide me with the regul...

Regular expression, remove the last specific character in the string with jQuery

I want to continue one task because my head has some problem with a regular expression. How can it be done with a regular expression and jQuery? I have this HTML: <div class="test">&nbsp;&gt;&nbsp;&nbsp;&gt;&nbsp;Presentation Text </div> And I want to get just this text from all this string, every time at the beginning I have " &...

help with Regex - need up to 3 number after the dot (.)

I need help with a regex matching a number. I need up to 3 digits after the dot (.): 12345 ok 12 ok 12.1 ok 12.12 ok 12.123 ok 12.1234 Error 1.123456 Error how to do it? Thanks in advance. ...

Regular Expression question

Hi guys: Could you expand on why the output of Console.WriteLine(m.Groups[1]); would be "Contoso, Inc"? And could you also elaborate on the matching steps of this example? Thanks. PS: I'm not familar with the concept of groups string input = "Company Name: Contoso, Inc."; Match m = Regex.Match(input, @"Company Name: (.*$)"); Conso...

Regex problem (PHP)

[quote=Username here]quoted text here[/quote] Reply text here I need a regular expression that stores the "Username here", "quoted text here" and "Reply text here" in a Array. This expression needs to support nesting aswell. Eks: [quote=Username2 here][quote=Username here]quoted text here[/quote] Reply text here[/quote] Reply text...

String parsing with RegExp in Actionscript

I have a string that is similar to a path, but I have tried some regex patterns that are supposed to parse paths and they don't quite work. Here's the string f|MyApparel/Templates/Events/ I need the "name parts" between the slashes. I tried (\w+) but the array came back [0] = "f" and [1] = "f". I tested the pattern on http://w...