regex - Ensuring a matched string contains at least one uppercase character -
given string
"this uppercase test url (http://www.somedomain.com/some/path). lowercase test url (http://www.somedomain.com/some/path)"
i have regex find urls:
\(http://www.somedomain.com/(.*?)\)
can amend return url if contains uppercase character in path?
you can put positive lookahead check uppercase character:
(?=\s*[a-z])\(http://www.somedomain.com/(.*?)\) ^^^^^^^^^^^^
it'll make sure there's @ least 1 uppercase character in string.
if want make sure 'check' remains within brackets, can use this:
\((?=[^)\s]*[a-z])http://www.somedomain.com/(.*?)\)
Comments
Post a Comment