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.

regex101 demo


if want make sure 'check' remains within brackets, can use this:

\((?=[^)\s]*[a-z])http://www.somedomain.com/(.*?)\) 

regex101 demo


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -