regex

Using Regex in SQL Server, I couldn't solve the following problem.

Hello all, I have strings like that OPEN SYSTEMS SUB GR (GM/BTIB(1111)/BTITDBL(2222)/BTVY(4444)/ACSVTYSAG) and I need to extract 2222 from it. What I was doing is this on the GROUPS String: SUBSTRING(GROUPS, CHARINDEX('(',GROUPS, CHARINDEX('(',GROUPS, CHARINDEX('(',GROUPS,0)+1)+1)+1, 4 ) AS GroupNo However I see that it is no...

Finding HTML strings in document - Regex - C#

I want to get all HTML <p>...</p> in a document. Using Regex to find all such strings using: Regex regex = new Regex(@"\<p\>([^\>]*)\</p\>", RegexOptions.IgnoreCase); But I am not able to get any result. Is there anything wrong with my regular expression.? For now, I just want to get everything that comes in between <p>...</p> tags a...

regex and substitution in java

I am trying to strip and replace a text string that looks as follows in the most elegant way possible: element {"item"} {text { } {$i/child::itemno} To look like: <item> {$i/child::itemno} Hence removing the element text substituting its braces and removing text and its accompanying braces. I believe the appropriate ...

Regex that matches Camel and Pascal Case

I'm about to write a parser for a language that's supposed to have strict syntactic rules about naming of types, variables and such. For example all classes must be PascalCase, and all variables/parameter names and other identifiers must be camelCase. For example HTMLParser is not allowed and must be named HtmlParser. Any ideas for a r...

Match only beginning of line in Ruby regexp

I have a string variable that has multiple newlines in it and I'd like to test if the beginning of the string matches a regular expression. However, when I use the ^ character, it matches against text that begins at each newline. I want this to match: "foo\nbar" =~ /^foo/ and I want this to not match "bar\nfoo" =~ /^foo/ I can't ...

Regular Expression to Locate unpaired quotation marks

I've got CSV data as follows: 1,poster,1,20# Recycled Bond,"4/0, colour master",16.5x23.4",trim ,files in colour attachments COH001 - 2556712,,FSC,,, 8,"Tags (#1-5,7-9)",8,20# Recycled Bond,"4/0, colour master",7x3 ",trim 1,Tags (#6),1,20# Recycled Bond,"4/0, colour master",7x3,trim ,files in colour attachments COH001 - 2556712,,FSC,,,...

Regular Expression for determining serial number

Hi, I know there are plenty of questions on SO asking for regex help so I apologise in advance for yet another. I've never used regular expressions before and I've searched online (and downloaded a program to show you the results of your regex) but I can't seem to figure the darn thing out myself which is annoying because I know it's re...

python, regex to find anchor link html

I need a regex in python to find a links html in a larger set of html. so if I have: <ul class="something"> <li id="li_id"> <a href="#" title="myurl">URL Text</a> </li> </ul> I would get back: <a href="#" title="myurl">URL Text</a> I'd like to do it with a regex and not beautifulsoup or something similar to that. Does anyone ...

How to use Regex.Split on this String?

Does anyone know how to write a Regex.Split in order to convert {video="my/video/file.flv,my/location.jpg"} into my/video/file.flv my/location.jpg ...

Ensure string start and end can be matched, otherwise fail regex

Hey there, I have this regex: {link=([^|{}]+)|([^|{}]+)|([^|{}]+)} this works great and returns me three groups between the pipe symbols, ie. this, that and blah from {link=this|that|blah}. As long as the text contains no pipe, or two curly braces (as they are reserved words in my tag builder.) However I am still getting a match if ...

PHP PCRE (regex) isn't doesn't support UTF-8?

I am attempting to run a regex on my site, and I am getting this response: Compilation failed: support for \P, \p, and \X has not been compiled at offset 1 After googling for a bit, I've found that apparently my PCRE on my server is not UTF8 enabled, and is therefore causing problems. When I ssh with pcretest -C I get PCRE ver...

Need help with back-reference matching on regex

Hey there, I have been working on this regex: {link=([^|{}]+)\||([^|{}]+)\||([^|{}]+)} I wish to capture any non-pipe or bracket chars and place them in appropriate backreference (group). How can I return the following: If test string is {link=a} return a into group 3. If test string is {link=a|b} return a into group 2, b into group...

Basic web-address validation regex?

Hello! I am looking for a regex that validates simple website addresses, i.e. http://www.stackoverflow.com www.stackoverflow.com stackoverflow.com stack-overflow.co.it I need it for contact details, 'Website' field, then when user click it opens IE, it doesn't have to be strict, I just don't want the user to enter 'I love milk' or ...

How to extract rows from a log file using Windows command line tools or batch file?

I would like to extract certain rows from a log file using native Windows command line tools or batch file (.bat). Here's a sample log file: 2009-12-07 14:32:38,669 INFO Sample log 2009-12-07 14:32:43,029 INFO Sample log 2009-12-07 14:32:45,841 DEBUG Sample log 2009-12-07 14:32:45,841 DEBUG Sample log 2009-12-07 14:32:52,029 WARN Sam...

How can I match mixed whitespace and () in Perl?

How do I improve my Perl regex to handle the __DATA__ below? my ($type, $value) =~ /<(\w+)\s+(.*?)\(\)>/; __DATA__ <dynamic DynamicVar> <dynamic DynamicVar > # not need attache the blackspace to $value when return <dynamic DynamicFun()> <dynamic DynamicFun() > # not need attache the blackspace to $value when return I want to return...

VB.NET: Regular Expression needed to replace return character with another string.

I'm trying to replace all the carriage return characters in a string obtained from a multi line text box in a Windows Form with the string ", <BR>" so that when I use the string in some HTML it displays correctly. Function Blah(ByVal strInput As String) As String Dim rexCR As Object rexCR = CreateObject("VBScript.RegExp") rexCR.Pa...

Matching all words except one

Say I have a sentence: I am a good buy and bad boy too How to select every word except boy in this sentence using regular expression ? ...

in PHP, how to remove specific class from html tag?

given the following string in PHP: $html = "<div> <p><span class='test1 test2 test3'>text 1</span></p> <p><span class='test1 test2'>text 2</span></p> <p><span class='test1'>text 3</span></p> <p><span class='test1 test3 test2'>text 4</span></p> </div>"; I just want to either empty or remove any class that has "test2" in it, so the resu...

Regular expression replacement

Hi, I ve got the following reg exp (-[^\w+])|([\w+]-[\w+]) I want to use it to replace dashes with a whitespace test -test should not be replaced test - test should be replaced test-test should be replaced So only if test -test the dash should NOT be replaced. Currently ([\w+]-[\w+]) is replaci...

How can I match strings that don't match a particular pattern in Perl?

I know that it is easy to match anything except a given character using a regular expression. $text = "ab ac ad"; $text =~ s/[^c]*//g; # Match anything, except c. $text is now "c". I don't know how to "except" strings instead of characters. How would I "match anything, except 'ac'" ? Tried [^(ac)] and [^"ac"] without success. Is it ...