Reputation: 2945
I need to extract filename in those formats like filename=FileName.Extension.
I have a Regex pattern, but when I test it it returns only 1 match instead 2.
What is wrong with this pattern?
pattern:
(?<=filename=).+\..+
test string::
idman636build5.exe?b=1&filename=idman636build5.exeidman636build5.exe?b=1&filename=idman636build5.exe
Expected matches:
filename=idman636build5.exeidman636build5.exe?b=1&filename=idman636build5.exe
filename=idman636build5.exe
The regex engine is .NET's default engine. I don't know the name of it.
Upvotes: 0
Views: 71
Reputation: 7426
I guess you want to consider the end of the filename to be the ?
or &
character. Changing the expression to match anything up to either character:
(?<=filename=)[^&?]+
Upvotes: 1
Reputation: 4288
The last .+
will match the second one since it says match anything. (?<=filename=).+\..+\n
this way only the first is matched for example.
Upvotes: 0