Reputation: 554
I would like to combine a few expressions to get 3 different results per line.
Example:
element\data\elements.data|44a0b61d1952973f52ad54cb911c0e3e|33095223
.*?element(?:(?!\|).)*
retrieves element\data\elements.data
(?<=\|)(.*?)(?=\|)
retrieves 44a0b61d1952973f52ad54cb911c0e3e
(?<=\|)[0-9]*\r
retrieves 33095223
But for me to get these I currently am doing 3 different RegEx, and I would like to limit it down to only one to get the 3 results I need and set them to different variables.
I have looked into doing a Dictionary
but those only allow 2 variables, while I need 3.
Upvotes: 2
Views: 148
Reputation: 6366
For having a Regex with multiple matches you should take a look add | between your expressions. This will then return you all the results matching any of the pattern, with no distinction which string was found by which match.
Upvotes: 0
Reputation: 66449
You could just split on the vertical pipe:
var elements = string.Split('|');
The resulting string array would contain:
Upvotes: 7