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,071 times
9
Alexey Kulikov
- 1,069
- 1
- 14
- 34
-
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
15
Use *? to make the * non-greedy.
NightOwl888
- 53,678
- 21
- 130
- 204
-
1Then you should tag it and credit @NightOwl888 as the correct/best answer. – Nicholas Carey Mar 17 '15 at 17:35