regex get a match
c#, regex
Solution
You need to escape `|` and `^`, as those are special characters in a Regex.
@"\|([A-Z]{3})\^([A-Z]{1})([0-9]{2})\|"
Or if you don't like verbatim literals:
"\\|([A-Z]{3})\\^([A-Z]{1})([0-9]{2})\\|"
Note that verbatim literals (using `@` before the opening quote) make regexes SIGNIFICANTLY more readable (and more portable -- now you can just copy/paste that regex somewhere else). You should always use verbatim literals with regex strings unless you have a very good reason to do otherwise.
Problem
How can i get `|ADT^A05|` out of "MSH|^~\&|PHTADT09|ABC|DADIST00|ABC|20120425152829|rcalini1|ADT^A05|20429208851634|P|2.1|560" I have tried this but not working ``` "|([A-Z]{3})^([A-Z]{1})([0-9]{2})|" ```