regex

AS3 Regular Expression Question...

Can someone give me a regular expression that will verify if all the letters in the word "cat" were also in the word "coating" in the proper sequence? So for the word "coating", the RegEx will test true for "cat" but false for "act". ...

Mathematica regular expressions on unicode strings.

This was a fascinating debugging experience. Can you spot the difference between the following two lines? StringReplace["–", RegularExpression@"[\\s\\S]" -> "abc"] StringReplace["-", RegularExpression@"[\\s\\S]" -> "abc"] They do very different things when you evaluate them. It turns out it's because the string being replaced in the ...

Regular expression .Net replace single characters followed by spaces at the beginning of string

I need to replace "x y z word1 word2" with "x_y_z word1 word2" The number of single characters may vary. ...

PHP regex help with preg_match_all

Hi, I am trying to refine a preg_match_all by finding the second occurrence of a period then a space: <?php $str = "East Winds 20 knots. Gusts to 25 knots. Waters a moderate chop. Slight chance of showers."; preg_match_all ('/(^)((.|\n)+?)(\.\s{2})/',$str, $matches); $dataarray=$matches[2]; foreach ($dataarray as $value) { echo $val...

Regarding parser DOM and REGEX

Hi I am writing an application in java I need to fetch specific data from website.I do not know which one to use whether REGEX or Parser.Can anybody please advise me how to get this done? and which one is prefered. Thanks ...

How to match a fixed number of digits with regex in PHP?

I want to retrieve the consecutive 8 digits out of a string. "hello world,12345678anything else" should return 12345678 as result(the space in between is optional). But this should not return anything: "hello world,123456789anything else" Because it has 9 digits,I only need 8 digits unit. ...

Replace text with other text in the same line

I don't know if I can use regex for this, but I want to replace something in this xml: <custom-attribute name="Attribute_1" dt:dt="string">Danny Boyle</custom-attribute> <custom-attribute name="DVD-releasedatum" dt:dt="string">06/10/1999</custom-attribute> should become <Attribute_1>Danny Boyle</Attribute_1> <DVD-releasedatum>06/10/1...

Naming convetion of regex,lookahead and lookbehind

Why is it counter intuitive? /(?<!\d)\d{8}(?!\d)/,here (?<!\d) comes first,but called lookbehind,(?!\d) next,but called lookahead.All are counter intuitive. What's the reason to name it this way? ...

PHP regular expressions question?

I really don't understand regular expressions and was wondering what the following regular expressions do I wanted my address and name to except periods hyphens letter uppercase and lowercase and numbers. Is my regular expressions living up to there job and is there need for improvement? Plus if some one can break down the regular expre...

Apache RewriteRule: it is possible to 'detect' the first and second path segment?

Im really really a newbie in regexp and I can’t figure out how to do that. My goal is to have the RewriteRule to 'slice' the request URL path in 3 parts: example.com/foo #should return: index.php?a=foo&b=&c= example.com/foo/bar #should return: index.php?a=foo&b=bar&c= example.com/foo/bar/baz #should return: index.php?a=foo&b=bar&c=ba...

PHP email validation question?

Will this email validation allow foreign email address like russian, hebrew and so on? And how can I just check for the @ sign? Here is the php code. if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $_POST['email'])) { $email = mysqli_real_escape_string($mysqli, strip_tags($_POST['email'])); } else { echo '<p class="error"...

How to match only extensionless URLs?

I want a regex expression which only match extensionless url. In otherwords if an extension is present in url then completely ignore it. /(.+)/(.+) this will match an URL both with and without extension. www.site.com/sports/cricket should match www.site.com/sports/cricket.aspx shouldn't match Thanks in advance ...

Regular expression for git repository

What will be proper regular expression for git repositories? example link: git@github.com:someone/someproject.git so it will be like server can be url or ip Project can contain some other characters than alphanumeric like '-' I'm not sure what is the role of '/' any suggestions? ...

RegExp: want to find all links that do not end in ".html"

Hi, I'm a relative novice to regular expressions (although I've used them many times successfully). I want to find all links in a document that do not end in ".html" The regular expression I came up with is: href=\"([^"]*)(?<!html)\" In Notepad++, my editor, href=\"([^"]*)\" finds all the links (both those that end in "html" and thos...

java regex: capture multiline sequence between tokens

I'm struggling with regex for splitting logs files into log sequence in order to match pattern inside these sequences. log format is: timestamp fieldA fieldB fieldn log message1 timestamp fieldA fieldB fieldn log message2 log message2bis timestamp fieldA fieldB fieldn log message3 The timestamp regex is known. I want to extract eve...

PHP regex to extract Twitpic link/code if present

I would like to be able to check a string of text and extract a twitpic url if it is present in the string, ultimately I would like just the code portion, but either will do. Example: "blah blah blah http://twitpic.com/1aso4q blah blah" Desired result: http://twitpic.com/1aso4q or 1aso4q Anyone able to help? ...

Regex negative look-behind in hgignore file

I'm looking for a way to modify my .hgignore file to ignore all "Properties/AssemblyInfo.cs" files except those in either the "Test/" or the "Tests/" subfolders. I tried using the negative look-behind expression (?<!Test)/Properties/AssemblyInfo\.cs$, but I didn't find a way to "un-ignore" in both folders "Test/" and "Tests/". ...

Regex: replace inner string

I'm working with X12 EDI Files (Specifically 835s for those of you in Health Care), and I have a particular vendor who's using a non-HIPAA compliant version (3090, I think). The problem is that in a particular segment (PLB- again, for those who care) they're sending a code which is no longer supported by the HIPAA Standard. I need to l...

Regexp: Replace only in specific context

In a text, I would like to replace all occurrences of $word by [$word]($word) (to create a link in Markdown), but only if it is not already in a link. Example: [$word homepage](http://w00tw00t.org) should not become [[$word]($word) homepage](http://w00tw00t.org). Thus, I need to check whether $word is somewhere between [ and ] and on...

Regex negative match query

Hey guys, I've got a regex issue, I'm trying to ignore just the number '41', I want 4, 1, 14 etc to all match. I've got this [^\b41\b] which is effectively what I want but this also ignores all single iterations of the values 1 and 4. As an example, this matches "41", but I want it to NOT match: \b41\b ...