I'm trying to create a regex that matches a URL that has a capital letter before the query string. I want to capture the query string including the question mark and I want to capture the non-query string part. If there is no query string, but there is a capital letter, then the non query string part should be captured.
A few examples:
/contextroot/page.html?param1=value1¶m2=value2 NO MATCH
/contextroot/page.html?param=VALUE¶m2=value2 NO MATCH
/contextroot/Page.html?param=value MATCH
/contextroot/Page.html GROUP 1
?param=value GROUP 2
/contextroot/page.HTML MATCH
/contextroot/page.HTML GROUP 1
Here's my first cut at the regex:
^(.*[A-Z].*)(\??.*)$
It's busted. This never captures the query string.