Regular Expressions announcement
-
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
-
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.
Filter
:
All Threads
All Threads
Answered
Unanswered
Proposed Answers
General Discussion
No Replies
Helpful
Has Code
All Languages
-
Sticky2Votes.Net Regex Tool - Regex Pixie
Hi Everyone, I'm a C# MVP and Regex enthusiast and I wanted to share a tool I just published called Regex Pixie. It is completely cost, registration and ... -
Sticky35VotesPassword Strength Expression
It's been a while since I've had to use regular expressions. Can someone explain this to me in layman's terms? ^(?=.{8,30})(?=.*[^A-Za-z])(?=.*[A-Z])(?=.*[a-z]).* -
Sticky2VotesHow to Ask A Regular Expression Question
Don't confuse the end goal with what needs to be done. A lot of people like to tell about where the data will go, or how its manipulated. Frankly we don't care. Provide a clear example of the ... -
Sticky6VotesRegex 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 ... -
Sticky28Votes.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 ...
-
Answered0VotesREGEX 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 ... -
Answered0VotesNeed 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 ... -
Answered0VotesWhat 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 ... -
Answered0Votesdifference 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 ... -
Answered0VotesRegular Expression Matching and Parsing a string
EXTRACT MT01E01 Last Started 2012-12-21 03:14 Status RUNNING Checkpoint Lag ... -
Answered1Votesregular 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 ... -
Answered0VotesWhole 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 ... -
Answered2VotesHow 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 ... -
Answered5VotesI 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 ... -
Answered0VotesVB 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" ... -
Answered2Votes.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 ... -
Answered3VotesReplace 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 ... -
Answered1Votesget data from tag
Hi all <Textbox Name="textbox158" ... -
Answered1VotesFind 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 ... -
Discussion28Votes.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 ... -
Answered1VotesPrepending 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 + ... -
Answered0Votesfind 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? -
Answered2VotesHow to use culture invariant for Regular expression ?
class Program { static void Main(string[] args) ... -
Answered0VotesValidationExpression for alpha-numeric values
Hi, TextBox should not accept only numeric values and only special characters. It can accept alpha-numeric values. ................. Thanks & ... -
Answered0VotesGet everything after ;#
Hi All, I have a string that has: numbers;#TextSpacesCommasSpecialCharacters How to I get everything to the right of ;# I have the ... - Items 1 to 20 of 2529 Next ›


