Regular Expressions announcement
-
Link
This forum is locked; it is still available for review in the Archived Forums folder. Any future posts on this topic should be put in the .NET Framework Class Libraries forum.
-
Link
If you love Regex...then Regex and Linq is a match made in Heaven. Here are two scenarios where Regex and linq can be used together.
- Place Key Value Pairs into a dictionary<string,string> object from regex: Regex To Linq to Dictionary in C#
Here is a quick example where this input "123abcd3" will tokenized into digits or characters and placed into an IEnumerable array with values of "123", "abcd" and "3".
The tokenization will occur and the named match Tokens will contain sub captures. Those captures will be enumerated and placed into an IEnumerable <string> array.string input = "123abcd3"; string pattern = @"(?<Tokens>\d+|[a-zA-Z]+)+"; var items = from Match m in Regex.Matches( input, pattern ) from Capture cpt in m.Groups["Tokens"].Captures select cpt.Value; Console.WriteLine( string.Join( ",", items.ToArray() ) ); // Outputs // 123,abcd,3
This should get you started in using Linq with Regex. GL HTH
-
6 VotesRegex Substraction of Character Set
(Moderator: I have split this post from its original because its an excellent learning tool concerning the set subtraction) Do you know what the following pattern does (without running ...Sticky | 10 Replies | 24407 Views | Created by xalnix - Thursday, August 13, 2009 8:34 PM | Last reply by JohnGrove - Wednesday, September 7, 2011 6:31 PM -
28 Votes.Net Regex Resources Reference
For those starting out with Regex'es or even those who are old hands here are some resources to help. .NET Framework Developer's ...Sticky | 5 Replies | 54751 Views | Created by OmegaMan - Friday, January 19, 2007 7:51 PM | Last reply by David Scherfgen - Monday, December 10, 2012 12:42 PM
Found 2524 threads
-
0 VotesREGEX How to return multiple named groups using multiple expressions
Hi all, I may be pushing it a little, trying to do this in one pattern... I have string data that I am trying to "read" and extract the important ...Answered | 2 Replies | 6204 Views | Created by gregc66 - Friday, December 28, 2012 10:47 PM | Last reply by Joel Engineer - Monday, December 31, 2012 11:19 PM -
0 VotesNeed some help figuring out my regex mystery.
Short Version: I am trying to build the regex to find out if a string contains "0,0,0,0". Every attempt I have made only returns each char as a match not the full string within the ...Answered | 2 Replies | 5079 Views | Created by JoetheWinDev - Thursday, December 27, 2012 7:40 AM | Last reply by OmegaMan - Friday, December 28, 2012 4:37 PM -
0 VotesWhat does it take to do this really simple match?
Merry Christmas everyone! Thanks for looking at this for me. You can sure improve my Christmas if you can help me with this. I have a really simple string ...Answered | 2 Replies | 5488 Views | Created by eBob.com - Tuesday, December 25, 2012 7:44 PM | Last reply by eBob.com - Thursday, December 27, 2012 8:08 PM -
0 Votesdifference of a{2} and a{2,}
it has to check the next character which is also 'a' (three 'a's) and the next one is end of string (that does not match our pattern) so the final match is 'aaa' 'aaa' -match ...Answered | 3 Replies | 5073 Views | Created by Jakub Jareš - Tuesday, December 25, 2012 8:50 AM | Last reply by Mike Feng - Wednesday, December 26, 2012 3:16 AM -
0 VotesRegular Expression Matching and Parsing a string
EXTRACT MT01E01 Last Started 2012-12-21 03:14 Status RUNNING Checkpoint Lag ...Answered | 3 Replies | 6525 Views | Created by Chirag Shah - Friday, December 21, 2012 6:46 PM | Last reply by Petalvik - Sunday, December 23, 2012 5:06 PM -
1 Votesregular expression for telecommunications Circuit ID please..
Guys, I am looking for regular expression for the below formats..i have been trying for few days ..see if you can help me with ...Answered | 9 Replies | 7856 Views | Created by Prakash Athikesavan - Monday, July 30, 2012 5:34 PM | Last reply by Prakash Athikesavan - Friday, December 21, 2012 4:03 PM -
0 VotesWhole word match when wildcard exist in search pattern
Hi all, I encounter a case when using Regex. My search pattern is like "He*lo", and I want to find whole word matched only. So my ...Answered | 6 Replies | 6798 Views | Created by Mohammed Stephan - Thursday, December 20, 2012 9:01 AM | Last reply by Joel Engineer - Friday, December 21, 2012 8:59 AM -
2 VotesHow can I decorate a field with RegularExpression attribute?
Hello msdn, Suppose, I am decorating an Ado.Net class for an entity framework based application with a RegularExpression attribute to validate the field, same as sql server ...Answered | 3 Replies | 6536 Views | Created by salam.p.v - Wednesday, December 19, 2012 6:15 PM | Last reply by Mike Feng - Thursday, December 20, 2012 4:45 AM -
5 VotesI want a Regex for Decimal(10,4)
Hello msdn, I want a regular expression for Decimal(10,4), means Maximum 10 digits, after decimal point(only 4 allowed). How can I write Regex ...Answered | 11 Replies | 31375 Views | Created by salam.p.v - Wednesday, December 19, 2012 1:10 PM | Last reply by salam.p.v - Thursday, December 20, 2012 4:24 AM -
0 VotesVB 2008 Regex Parsing HTML With HTTPWebRequest Implementation...
Here is the html that I'm trying to parse: <img src="//i4.ytimg.com/i/KsgLc1nSqX4RZXrSZrxDBg/1.jpg?v=5061f26c" alt="NYSGOV" ...Answered | 7 Replies | 7798 Views | Created by TeachMe - Wednesday, December 12, 2012 4:10 AM | Last reply by Jesse Houwing - Tuesday, December 18, 2012 5:04 PM -
2 Votes.NET Framework Regular Expressions
I have some problem with regex. String which I need to find has two parts: VOT_.string_n, where n can bee 1, 2, 3, 4, ... How could I find second part of string ...Answered | 4 Replies | 5739 Views | Created by Tokimes - Monday, December 17, 2012 4:32 PM | Last reply by Jesse Houwing - Monday, December 17, 2012 9:02 PM -
3 VotesReplace Question
Hi, I am trying to do a Replace and I'm not getting what I expect. I think that I am following an example in the great book by Francesco Balena but apparently ...Answered | 2 Replies | 6005 Views | Created by eBob.com - Saturday, December 15, 2012 5:35 PM | Last reply by eBob.com - Saturday, December 15, 2012 6:32 PM -
1 Votesget data from tag
Hi all <Textbox Name="textbox158" ...Answered | 5 Replies | 5558 Views | Created by chezhian_in05 - Monday, December 10, 2012 3:42 PM | Last reply by Jesse Houwing - Wednesday, December 12, 2012 12:41 PM -
1 VotesFind in files: lines containing await but not ConfigureAwait(false)
Hi. That is a personnal choice (which may be discussed on another topic), but I'd like to use a regular expression using edit/find in files to detect lines in my solution that ...Answered | 6 Replies | 6136 Views | Created by Sylvain De - Saturday, December 8, 2012 12:25 PM | Last reply by Ron Rosenfeld - Monday, December 10, 2012 1:14 PM -
28 Votes.Net Regex Resources Reference
For those starting out with Regex'es or even those who are old hands here are some resources to help. .NET Framework Developer's ...Discussion | 5 Replies | 54751 Views | Created by OmegaMan - Friday, January 19, 2007 7:51 PM | Last reply by David Scherfgen - Monday, December 10, 2012 12:42 PM -
1 VotesPrepending a base url to all image tags in HTML source?
I'm looking for an efficient way to find all occurrences of image tags (and links) within an HTML file, and insert a base url before the protocol + ...Answered | 1 Replies | 6438 Views | Created by RectangleEquals - Saturday, December 8, 2012 6:52 PM | Last reply by Pieter Geerkens - Sunday, December 9, 2012 11:25 AM -
0 Votesfind lines with both words
I want to find lines which contain both the words WriteLine and count but can't seem to find some kind of and operator. What is the way to do that?Answered | 2 Replies | 5337 Views | Created by Serve Laurijssen - Wednesday, December 5, 2012 7:22 AM | Last reply by Mike Feng - Wednesday, December 5, 2012 12:57 PM -
2 VotesHow to use culture invariant for Regular expression ?
class Program { static void Main(string[] args) ...Answered | 3 Replies | 9229 Views | Created by Manjula.C - Tuesday, December 4, 2012 1:06 PM | Last reply by Pieter Geerkens - Wednesday, December 5, 2012 7:59 AM -
0 VotesValidationExpression for alpha-numeric values
Hi, TextBox should not accept only numeric values and only special characters. It can accept alpha-numeric values. ................. Thanks & ...Answered | 3 Replies | 6733 Views | Created by yogi3188 - Monday, November 26, 2012 6:26 AM | Last reply by Deepak Kalra - Wednesday, December 5, 2012 5:35 AM -
0 VotesGet everything after ;#
Hi All, I have a string that has: numbers;#TextSpacesCommasSpecialCharacters How to I get everything to the right of ;# I have the ...Answered | 1 Replies | 4764 Views | Created by KonaCoffee - Tuesday, December 4, 2012 5:25 PM | Last reply by Pieter Geerkens - Tuesday, December 4, 2012 5:31 PM - Items 1 to 20 of 2524 Next ›
Regular Expressions announcement
-
Link
This forum is locked; it is still available for review in the Archived Forums folder. Any future posts on this topic should be put in the .NET Framework Class Libraries forum.
-
Link
If you love Regex...then Regex and Linq is a match made in Heaven. Here are two scenarios where Regex and linq can be used together.
- Place Key Value Pairs into a dictionary<string,string> object from regex: Regex To Linq to Dictionary in C#
Here is a quick example where this input "123abcd3" will tokenized into digits or characters and placed into an IEnumerable array with values of "123", "abcd" and "3".
The tokenization will occur and the named match Tokens will contain sub captures. Those captures will be enumerated and placed into an IEnumerable <string> array.string input = "123abcd3"; string pattern = @"(?<Tokens>\d+|[a-zA-Z]+)+"; var items = from Match m in Regex.Matches( input, pattern ) from Capture cpt in m.Groups["Tokens"].Captures select cpt.Value; Console.WriteLine( string.Join( ",", items.ToArray() ) ); // Outputs // 123,abcd,3
This should get you started in using Linq with Regex. GL HTH
