Reputation: 1147
I have a string like fcsNotificationZK44_0376300009215000019_4158794.xml
and a pattern (fcs.*)_
the target is to get fcsNotificationZK44
but standart C# Regex
matched at fcsNotificationZK44_0376300009215000019
becouse it is greedy. In javascript I can use /U
modifier to turn on ungreedy mode but how to solve it in C# Regex
? Thanks.
Upvotes: 12
Views: 4276
Reputation: 56869
Use *?
to make the *
non-greedy.
Reference: http://www.regular-expressions.info/repeat.html
Upvotes: 18