Regex Or and Greedy -


i trying perform regex not sure how write or condition because of greedy behavior of regex.

some_text=(?<value>.*)&|some_text=(?<value>.*)$ 

the above regex want write better 1 following:

some_text=(?<value>.*)(?:&|$) 

but because of greediness, 1 not stopping value when encounters first & instead goes end of string.

thanks help

you can use negation regex:

some_text=(?<value>[^&]*) 

[^&]* match 0 or more of character not &


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -