Regex Parsing
suggest changeSyntax
var regex = new Regex(pattern);//Creates a new instance with a defined pattern.regex.Match(input);//Starts the lookup and returns the Match.regex.Matches(input);//Starts the lookup and returns a MatchCollection
Parameters
| Name | Details|
| ------ | ------ |
| Pattern | The `string` pattern that has to be used for the lookup. For more information: https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx |
| RegexOptions *[Optional]* | `Singleline` lets `.` match a newline. `Multiline` changes `^` and `$` so they match at line breaks; it does not change `.`. Default behaviour: https://msdn.microsoft.com/en-US/library/yd1hzczs(v=vs.110).aspx#Default |
| Timeout *[Optional]* | Where patterns are getting more complex the lookup can consume more time. This is the passed timeout for the lookup just as known from network-programming.|
Remarks
Needed using
using System.Text.RegularExpressions;
Nice to have
Beginners tend to overdo tasks with regex because it feels powerful and looks like the right tool for more complex text lookups. This is the point where people try to parse XML documents with regex without asking themselves whether a class such as XmlDocument already does the job.
Regex should be the last weapon to pick against complexity. At least don't forget to search for the right way before writing down 20 lines of patterns.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents