regex

Why is this character invisible in Visual Studio?

I've got a file, on which I'm doing some Regex. The file uses ASCII character 218, which is visible in notepad. When I copy the character into my VS2010, it doesn't appear! But it will still cause a compile error if I paste it in the wrong place, and when I run the program, it still appears in the search string when I mouse over it. The ...

definign a tag or pattern for xml schema

I am newbie in xml schema. Is there any possiblility to define that element starts with some characater or symbol. I mean to say, <xs:element minOccurs="1" maxOccurs="1" name="Header"> <xs:complexType> <xs:sequence> <xs:sequence> <xs:element maxOccurs="1" minOccurs="1" name="NAME_STUDENTS"> ...

regexp-like library for matrix pattern search

Is there a library (in any language) that can search patterns in matrixes like regular expressions work for strings ? Something like regular expresions for matrixes, or any matrix pattern search method ? ...

Pattern matches an hyphen too

I have a piece of Perl code (pattern matching) like this, $var = "<AT>this is an at command</AT>"; if ($var =~ /<AT>([\s\w]*)<\/AT>/i) { print "Matched in AT command\n"; print "$var\n\n"; } It works fine, if the content inbetween tags are without an Hyphen. It is not working if a hyphen is inserted between the string present...

Regex help. Lighttpd rewrite rule

Hi, I am not very familiar with Regular expression, but I am asked to modify a lighttpd rewrite rule. url.rewrite = ( "^/(.+)/?$" => "/index.php/$1" ) I want to exclude a path from the above greedy pattern, so that it won't fall back to index.php. In words, it is simple: Match anything other than "statistics". But I just couldn'...

Get substring with regular expression

Hi, I'm stuck with regular expression and Java.. My input string that looks like this: "EC: 132/194 => 68% SC: 55/58 => 94% L: 625" I want to read out the first and second values into two variables. Otherwise the string is static with only numbers changing. Update: By first and second value I mean 132 and 194. Sorry for being uncl...

Regex find specific tags for replace in a string

Hello all, I have a string with some codes (ex:«USER_ID#USERNAME#STATUS») for replacement like in this example: Hello «USER_ID#USERNAME#STATUS», do you like «PROD_ID#PRODNAME#STATUS»? I need to find a way to get all the codes for future replacement. I can easily find one code with this regex: /«(.*)#(.*)#(.*)»/ but can't f...

Code Golf: Regex parser

The goal Today's Code Golf challenge is to create a regex parser in as few characters as possible. The syntax No, I'm not asking you to match Perl-style regular expressions. There's already a very reliable interpreter for those, after all! :-) Here's all you need to know about regex syntax for this challenge: A term is defined as a...

Error with \^ in c# regex

I have a string that contains colours in the form of "^##" where ## can be 00-99. I wrote regex to detect and replace these colours: Input = Regex.Replace(Input, "\^[0-9][0-9]", ""); However the compiler doesn't seem to like \^ as a means of detecting the "^" character (gives an invalid escape code error). So how do I go about looking...

strtotime - always return NEXT [date here]

I'm trying to use the strtotime function in order to return the following date specified. For example: strtotime('thursday'); //Need to get NEXT Thurs, not today (assuming today is Th) Using next thursday would work in this case, but does not work with absolute dates, such as: strtotime('next aug 19'); //Should return 08-19-2011, but...

A RegEx problem in PHP.

I could not think of a proper title. I have some data like - $data = <<<EOD <strong> HHHHH <strong> TTTTT <strong> RRRRRRR <strong> EOD; Basically above one is just an example. In real, the data is like - <strong>Some Title</strong> DATA <strong>Some other Title</strong> OTHER DATA Sample: http://pastebin.com/cxzZWDZ8 Now I apply ...

Regex to strip line comments from C#...

I'm working on a routine to strip block or line comments from some C# code. I have looked at the other examples on the site, but haven't found the exact answer that I'm looking for. I can match block comments (/* comment */) in their entirety using this regular expression with RegexOptions.Singleline: (/\*[\w\W]*\*/) And I can match ...

Regular expression to match closing HTML tags

Hello! I'm working on a small Python script to clean up HTML documents. It works by accepting a list of tags to KEEP and then parsing through the HTML code trashing tags that are not in the list I've been using regular expressions to do it and I've been able to match opening tags and self-closing tags but not closing tags. The patter...

Regex subbing out 'section character' in java

I'm running a series of regex substitutions (i.e. String.replaceAll calls) to convert all the special characters in a text file to XML parseable special characters. For example: string_out = string_out.replaceAll("&", "&amp;"); I've hit a stumbling block replacing the 'section character' that is, this little squiggle: § For starters,...

Does this regex mean it has to start with A, end with Z? re.search "\A[0-9A-Za-z_-]+\Z"

Does this regex mean it has to start with A, end with Z? re.search("\A[0-9A-Za-z_-]+\Z", sometext) ...

Problems matching caret in Python regex

I have the following regular expression, which I think should match any character that is not alphanumeric, '!', '?', or '.' re.compile('[^A-z ?!.]') However, I get the following weird result in iPython: In [21]: re.sub(a, ' ', 'Hey !$%^&*.#$%^&.') Out[21]: 'Hey ! ^ . ^ .' The result is the same when I escape the '.' in the reg...

Regular expression that checks for 2 specific words

Hi there, I'm looking for a regular expression that checks whether a string contains 2 specific words. e.g. whether the string contains rooster or hen. Thanks in advance! ...

Separate key:value-string to NSDictionary

Hi, I have a string like this: "(list:\"RTM API\" status:completed)" And I want to convert it into a NSDictionary with the "value" before the colon as the key and the value left of the colon as the value - like this: list: "RTM API" status: "completed" It can probably be done using a simple regex or so, but I don't really know how...

Why doesn't the dot symbol work in this Regex?

Hello I have a .NET Regex. (with ignore-case) I want it to match field_x_12 field_a_ABC field_r_something etc My question is why the . operator doesn't work in this regex: field_[.]_.* yet this (equivalent basically) regex does work: field_[a-z]_.* Is there something I'm missing about the dot operator . ? ...

Regex problem: IsMatch method never returns

I have a regex issue that I need help with. Its trying to validate an Email address. Regex rx = new Regex(@"^[A-Za-z0-9]([_\.\-]?[A-Za-z0-9]+)*\@[A-Za-z0-9]([_\.\-]?[A-Za-z0-9]+)*\.[A-Za-z0-9]([_\.\-]?[A-Za-z0-9]+)*$|^$"); rx.IsMatch("john.gilbert.stu.seattle.washington.us"); The IsMatch method never returns for that particular strin...