Reputation: 59
I am attempting to create a regex that will match all uppercase letters before the first question mark in a URL string:
/foO/baR/?_heLLo=1320957051041105000&_woRld=0
I have tried both the following:
(?<!(\?))([A-Z])
(?<!\?.*?)([A-Z])
The former captures uppercase letters before and after the question mark. The latter captures no uppercase letters. Any insight would be appreciated, thanks.
Upvotes: 2
Views: 2077
Reputation: 12586
This regex would do the trick:
[A-Z](?=.*?\?)
See it in action here: http://regexr.com?2v5r0
Upvotes: 2