Make groups with regular expresion like in perl?
In Perl if I use this regex /(\w+)\.(\w+)/ on the string "1A3.25D", the global vars $1 strores "1A3" and $2 stores "25D". Is there a way to do this in C#? ...
In Perl if I use this regex /(\w+)\.(\w+)/ on the string "1A3.25D", the global vars $1 strores "1A3" and $2 stores "25D". Is there a way to do this in C#? ...
I have a job application form where people fill in their name and contact info and attach a resume. The the contact info gets emailed and the resume attached. I would like to change the name of the file to that it is a combination of the competition number and their name. How can I clean up my generated filename so that I can guarante...
Hi I have an emacs buffer containing the text a1b2c3 using the regexp-builder, i create the regexp "b\\(2\\)" and can see the match highlighting (b2, with the 2 in a different colour). however, when i paste the expression into replace-regexp, i get 0 matches. both with and without the quotes. to get a match i need to use b\(2\)...
While answering another question, it was brought up that there might a difference, performance-wise, between an explicit character class ([0-9]) and a "shorthand" class (\d). My initial reaction was that if a difference exists at all, it'd be negligible, but I don't have (and couldn't find) any info about it or figure out how I could tes...
I am receiving the left and right sides of a regular expression replacement as the arguments to a function. I want my users to be able to use capture buffers, but it doesn't work the way I'm trying to do it. my $string = "This is my string"; $string = regex_replace($string,'is (my) string','$1'); print "$string\n"; sub regex_replace...
{ Main Block { Nested Block } } { Main Block { Nested Block } { Nested Block } } I want to get data within Main Blocks including its Nested Blocks with Java Regex. Is it possible? Thanks in Advance ...
I am trying to find some mysterious bugs in an application, and believe the cause may be some hard casts on interfaces. Such casts are unsafe in Delphi, for example ISomeInterface(CurrentObj) which should be CurrentObj as ISomeInterface In light of the lack of compiler warnings which in my opinion should be emitted for hard cast...
Let presume we have something like this: <div1> <h1>text1</h1> <h1>text2</h1> </div1> <div2> <h1>text3</h1> </div2> Using RegExp we need to get text1 and text2 but not text3. How to do this? Thanks in advance. EDIT: This is just an example. The text I'm parsing could be just plain text. The main thing I want to accompli...
I need a regex that will match on a price or amount. It should match on these 100 410.00 0.12 but not these 100.000 -600.00 .12 .1234 This works for all of the above cases except for single values like 1 /^[0-9]*\.?[0-9]{2}+$/ How can I adjust it so single integers will match? And can anyone explain why the current one is wr...
I read from a lot of webpage (for example: http://www.wellho.net/regex/java.html), they all mentioned that \s could represent any space charactor. But when I use \s in Java, it is not an eligible expression. Anyone know the reason? ...
Usually when my regex patterns look like this: http://www.microsoft.com/ Then i have to escape it like this: string.match(/http:\/\/www\.microsoft\.com\//) Is there another way instead of escaping it like that? I want to be able to just use it like this http://www.microsoft.com, cause I don't want to escape all the special charact...
I'm trying to create a regular expression for matching latitude/longitude coordinates. For matching a double-precision number I've used (\-?\d+(\.\d+)?), and tried to combine that into a single expression: ^(\-?\d+(\.\d+)?),\w*(\-?\d+(\.\d+)?)$ I expected this to match a double, a comma, perhaps some space, and another double, but it ...
I am using URL Rewrite module 2 in IIS 7. I have a certain rule for rewriting URLs in IIS. But I want that rule to apply to only strings that DO NOT contain a DOT (.) If the string contains a DOT, I want it to fail and simply be not rewritten. I thought this will work - ^([^.]+) but it rejects only strings that start with a DOT. Examp...
Using PHP to curl a web page (some URL entered by user, let's assume it's valid). Example: http://www.youtube.com/watch?v=Hovbx6rvBaA I need to parse the HTML and extract all de-duplicated URL's that seem like an image. Not just the ones in img src="" but any URL ending in jpe?g|bmp|gif|png, etc. on that page. (In other words, I don't ...
I have list like: ['name','country_id', 'price','rate','discount', 'qty'] and a string expression like exp = 'qty * price - discount + 100' I want to convert this expression into exp = 'obj.qty * obj.price - obj.discount + 100' as I wanna eval this expression like eval(exp or False, dict(obj=my_obj)) my question is what would b...
I have a next string like: <img src="../uplolad/commission/ranks/avatar.jpg' . $row[$c_name] .'" width="50" height="50"/> How can i get a image file name in javascript? I know only PHP regexes. Extention of a file can be different. The result must be: avatar.jpg ...
I can't seem to find a good resource on this.. I am trying to do a simple re.place I want to replace the part where its (.*?), but can't figure out the syntax on how to do this.. I know how to do it in PHP, so I've been messing around with what I think it could be based on that (which is why it has the $1 but I know that isn't correct i...
I have the need to check whether strings adhere to a particular ID format. The format of the ID is as follows: aBcDe-fghIj-KLmno-pQRsT-uVWxy A sequence of five blocks of five letters upper case or lower case, separated by one dash. I have the following regular expression that works: string idFormat = "[a-zA-Z]{5}[-]{1}[a-zA-Z]{5}[-]...
Hi everyone, I'm parsing strings that could have any number of quoted strings inside them (I'm parsing code, and trying to avoid PLY). I want to find out if a substring is quoted, and I have the substrings index. My initial thought was to use re to find all the matches and then figure out the range of indexes they represent. It seems...
Dropping of the ereg-functions and their POSIX-regular expression flavor in later PHP versions? After reading an older posting concerned of this - and reading the official PHP statement I'm inclined to ask what this is about. Following the development of PHP over the years (and doing much development in Perl and PHP) I'm really unsure i...