Reputation: 5426
I have the following string:
authmod=adobe&user=ibrahimk04&challenge=5Axn6g==&response=3uy8NkHDVLpt0HwT8PraZg==&opaque=KuAj5Q==
I am using the below Regex in order to extract ibrahimk04
@"(user)=((\\w*)\\&)"
but it is returning user=ibrahimk04&. why ? it should return array with 2 ranges. am I wrong ?
Upvotes: 1
Views: 61
Reputation: 174696
Use lookaround assertions to match one or more word characters which are just after to user=
and followed by a &
symbol.
(?<=user=)\\w+(?=&)
OR
(?<=user=)\\w+
Explanation:
(?<=user=)
Positive look-behind asserts that the characters which are going to be matched must be preceded by user=
\\w+
Matches one or more word characters.(?=&)
Asserts that the matched word characters must be followed by a &
symbol.Upvotes: 1