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.
Asked
Active
Viewed 3,783 times
10
Alexey Kulikov
- 1,097
- 1
- 14
- 38
-
Does this answer your question? [Regex Non-Greedy (Lazy)](https://stackoverflow.com/questions/13844168/regex-non-greedy-lazy) – Heretic Monkey Jan 06 '21 at 17:30
2 Answers
16
Use *? to make the * non-greedy.
NightOwl888
- 55,572
- 24
- 139
- 212
-
1Then you should tag it and credit @NightOwl888 as the correct/best answer. – Nicholas Carey Mar 17 '15 at 17:35