regex

Iterating Regex Named Groups

I am trying to iterate each named group in a regular expression (i.e. - (?<name>.*)) and depending on the name of the group set an instance property or add it to a collection. Important part is I will never know the name of the group when using the regular expression so I cannot use the string indexer on my Match. Is there a way to ext...

Can you salvage my negative lookbehind example for commifying numbers?

In the "Advanced Regular Expresssion" chapter in Mastering Perl, I have a broken example for which I can't figure out a nice fix. The example is perhaps trying to be too clever for its own good, but maybe someone can fix it for me. There could be a free copy of the book in it for working fixes. :) In the section talking about lookaround...

Asp.net ValidationExpression

I'm looking for ValidationExpression to allow entering 9 or 10 or 11 or 12 digits. I used these Expressions but did not work with me. "\d{9}|\d{10}|\d{11}|\d{12}" "\d{9}|d{10}|d{11}|d{12}" "\d{9}?|d{10}?|d{11}?|d{12}?" any advice? ...

Helicon ISAPI Rewrite + ASP.NET : Rewrite rule to redirect to default page?

How do i rewrite URL like: http://subfoo.foo.com/ --> http://subfoo.foo.com/Pages/Home.aspx ...

How do I parse a string for a particular delimited section within PHP?

Hi folks, I have a string, for example "[{XYZ123}] This is a test" and need to parse out the content in between the [{ and }] and dump into another string. I assume a regular expression is in order to accomplish this but as it's not for the faint of heart, I did not attempt and need your assistance. What is the best way to pull the fr...

Regular Expression for matching string like: "<any_string>+<any_string>+<any_string>"

Regular Expression for matching string like: "<any_string>+<any_string>+<any_string>"? ...

How to Rewrite URL like: www.foo.com/tags/tag1+tag2 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1+tag2

How to add single rewrite rule for- www.foo.com/tags/tag1 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1 www.foo.com/tags/tag1+tag2 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1+tag2 www.foo.com/tags/tag1+tag2+tag3 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1+tag2+tag3 ...

Textparsing and splitting text including/excluding quotation marks

My question is almost identical to an earlier entry I found here but not quite. I need to parse through a textfile where the data is structured in this way: Each item in the file begins with a # followed by the label. The fields in the post is separated by one or more whitespaces. Here comes the part I'm having problem with. Each field...

regex (regular expressions) pattern NOT containing a string

It was already asked here, but the asker got satisfied with a 2 character finding answer. I repeat his basic question: Generally, is there any way, how to say not contains string in the same way that I can say not contains character with [^a]? I want to create a regexp that matches two ending strings and everything between, b...

Why is using a POSIX character class in my regex pattern giving unexpected results?

I have encountered some strange Perl behavior: using a Posix character class in a regexp completely alters the sort order for the resulting strings. Here is my test program: sub namecmp($a,$b) { $a=~/([:alpha:]*)/; # $a=~/([a-z]*)/; $aword= $1; $b=~/([:alpha:]*)/; # $b=~/([a-z]*)/; $bword= $1; return $aword cmp $bword; ...

Using Regular Expression in VC++

Hi , I am finding Email ids in mu project, where I am preprocessing the input using some Regular Expression. RegExpPhone6.RegComp("[\[\{\(][ -]?[s][h][i][f][t][ -]?[+-][2][ -]?[\]\}\)]"); Here while I am compiling i am getting a warning msg like Warning 39 warning C4129: ')' : unrecognized character escape sequence How can i...

Search and replace with regular expressions under Visual Studio 2003

I have a large C++ code base that I'm doing some refactoring on where a number of functions have become redundant, and hence should be removed. So I would like to replace MyFunc(Param) with Param where Param could be a literal value, variable, function call etc... From the online help I gathered that the search parameters should ...

Checking if a url is already submitted in database in php

Hello everybody, What i need get done is checking if a url is already submitted in database using php. I have a database table where i store URLS submitted by users. But i want to check if the urls are already submitted or not in the database before inserting it to the database. For example, URLS like http://www.example.com, http://www...

Replace path in Powershell string

Hi everyone, in my script I check some files and would like to replace a part of their full path with another string (unc path of the corresponding share). Example: $fullpath = "D:\mydir\myfile.txt" $path = "D:\mydir" $share = "\\myserver\myshare" write-host ($fullpath -replace $path, $share) The last line gives me an error since $p...

extract all email address from a text using c#

is there a way to extract all email address from a plain text,Using C# . eg my email address is [email protected] and his email is [email protected] should return [email protected],[email protected] I have tried following but it matches perfect emails only. public const string MatchEmailPattern = @"^(([\w-]+\.)+[\w-]+|([a-zA-Z...

URL matching using preg_match_all in PHP and regex

I am trying to build a crawler that gets the movie urls from an imdb list. I am able to get all the links on the page into an array and want to select only those ones with "title" in them. preg_match_all($pattern, "[125] => href=\"/chart/2000s?mode=popular\" [126] => href=\"/title/tt0111161/\" ", $matches); where $pattern='/title/'. ...

Walkingthrough of my project C# application?

I am planning to develop a C# application for my client. I need advices from well experienced dot net guys with restpect to SDLC. I want the walk thorugh of the project , which are the different steps that needs to be followed? Application is to parse the body of the email and put the filterd data into the excel file. Please advice m...

VB6: Regular Expressions - Problem under Win7

hi all, i have a little application which uses regular expressions under VB6. It works perfectly under XP but under Win7 i'm experiencing massive problems. sometimes, when the text which is passed to the regex function is > 20KB it freezes the application and also the whole win7 system: it's getting really slow, almost completely freeze...

Shell commands to match key value pairs

I've got a file that contains a list of key=value pairs, each on its own line. What's the best way to fetch the value for a specified key using shell commands? ...

Mass of text, cherry pick email addresses

Hello, I have a large file full of text and in there are some email addresses. Which php regular expression function would return an array of email addresses it could find? So far I have <?php $pattern = "/^[^@]*@[^@]*\.[^@]*$/"; if ($handle = opendir('files')) { /* This is the correct way to loop over the directory. */ while (fal...