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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -