Useful Regular Expression Tutorial
Hi I'm looking for a good tutorial on using regular expressions especially with grep. I tried googling for some but most tutorials are too basic and cover things I already know. ...
Hi I'm looking for a good tutorial on using regular expressions especially with grep. I tried googling for some but most tutorials are too basic and cover things I already know. ...
i want to get an ending html tag like </EM> only if somewhere before it i.e. before any previous tags or text there is no starting <EM> tag my sample string is ddd d<STRONG>dfdsdsd dsdsddd<EM>ss</EM>r and</EM>and strong</STRONG> in this string the output should be </EM> and this also the second </EM> because it lacks the starting <EM...
In (Visual Basic, .NET): Dim result As Match = Regex.Match(aStr, aMatchStr) If result.Success Then Dim result0 As String = result.Groups(0).Value Dim result1 As String = result.Groups(1).Value End If with: aStr equal to (whitespace is normal space and there is 7 spaces between "n" and "(" ): "AMEVDIEERPK + 7 Oxidat...
Ok, I need a regex for the following pattern: -Total of 5 characters (alpha and numeric, nothing else). -first character must be a letter (A,B,C only) -the remaining 4 characters can be number or letter. clarifcation: the first letter can only be A,B, or C. Example: A1234 is valid but D1234 is invalid. ...
I want to match any line that does not end with 'CA' or 'CA[any number]'. How can I do that using rlike in MySQL? (Note it doesn't support ?! etc). Here's the regex for a positive match, I just need a way to negate it: '^.*[C][A][0-9]?$' (Due to an embarrassing architecture limitation, I don't want to use not rlike ...) ...
Given the below XML snippet I need to get a list of name/value pairs for each child under DataElements. XPath or an XML parser cannot be used for reasons beyond my control so I am using regex. <?xml version="1.0"?> <StandardDataObject xmlns="myns"> <DataElements> <EmpStatus>2.0</EmpStatus> <Expenditure>95465.00</Expenditure> ...
I have used the following regex to get the urls from text (e.g. this is text http://url.com/blabla possibly some more text). '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@' This works for all URLs but I just found out it doesn't work for URLs shortened like: "blabla bla http://ff.im/-bEnA blabla" turns becomes http://ff.im/ a...
I've got a long regex in AS3 / Flex which finds one of a couple dozen words. The Regex looks like: word|wordup|wordly|wordster when I do "wordup wordster!".match(regex) I'm getting undefined maches! the match array that's returned has matches: [0] 'wordup' [1] undefined array length: 2 Is there a known bug in AS3's grouping ma...
Hi, I've got text in a form of [1/12/2008 2:32:11 p.m. - name] line 1 [1/12/2008 2:36:00 p.m. - name] - PRIVATE line 2 [some text] sd [1/12/2008 2:36:00 p.m. - name] line 3 which i want to split into items so i have access to time, name and text of each item, e.g.: (item 1) 1: 1/12/2008 2:32:11 p.m. 2: name 3: line 1 (item 2)...
I would like to have a regular expression that checks if a string contains only upper and lowercase letters, numbers, and underscores. ...
I have the following piece of code which replaces "template markers" such as %POST_TITLE% with the contents of a variable called $post_title. function replaceTags( $template, $newtext ) { $template = preg_replace( '/%MYTAG%/', $newtext, $template ); return $template; } The issue is that when $post_full has a '$' in it, the ret...
I'm looking for a method to grep for multiple atoms e.g. "foo" and "bar". I'm aware i can use grep 'foo' file | grep 'bar' to get both of them but i was wondering if there was a more efficient way. Any googleing seems to only throw results for an 'or' based search rather than 'and'. ...
A frequent issue in code reviews is whether a numeric value should be hard-coded in the code or not. Does anyone know of a nice regular expression that can catch 'magic numbers' in code like: int overDue = 30; Money fee = new Money(5.25D); without also getting a ton of false positives like for loop initialization code? for (int i = 0...
I'm attempting to find the best methodology for finding a specific pattern and then replace the ending portion of the pattern. Here is a quick example (in C#): //Find any year value starting with a bracket or underscore string patternToFind = "[[_]2007"; Regex yearFind = new Regex(patternToFind); //I want to change any of these va...
I've got an array of objects in json format: [{"name":"obj1", "list":["elem1", "elem2", "elem3"]}, {"name":"obj2", "list":["elem4", "elem5", "elem6"]}] Now I'd like to construct regexp to remove quotation marks from around elements in the "list" using javascript. Desirable result: [{"name":"obj1", "list":[elem1, elem2, elem3]}, {"name"...
Hi all, How best can I convert instances of double backslashes to a single backslash in a string, but remove any occurrences of single backslash? So this: \|Testing|ABC:1234\\1000-1\| Should convert to this: |Testing|ABC:1234\1000-1| Ideally I want to avoid a temporary replace of '\' to another character. A solution using .NET...
Can we write an regular expression such that it splits the stored procedure in multiple SQL statements. It should split update, delete select etc statements. ...
I want to do preliminary check if entered string looks like Vehicle Identification Number (VIN). I know what it consists of 17 letters and digits, but letters I, O and Q are not allowed inside VIN, so I use this regular expression: ^[0-9A-Z-[IOQ]]{17}$ Now if I check a string like 1G1FP22PXS2100001 with RegularExpressionValidator it f...
Hi, I need to use a datetime.strptime on the text which looks like follows. "Some Random text of undetermined length Jan 28, 1986" how do i do this? ...
H guys, I've got this wiki formatting algorithm which I am using at Stacked to create HTML out of "wiki syntax" and I am not really sure if the current one I am using is good enough, optimal or contains bugs since I am not really a "Regex Guru". Here is what I am currently using; // Body is wiki content... string tmp = Body.Replace("&",...