RegEx: Just the lowercase, just the lowercase

Hi

This is a regex question.

I am trying to match a set of URLs. Some of the URLs contain a GUID, something like this:

http://www.example.com/newsroom/press/release/?id=8a0223ba-af12-4406-a4a5-af603c0a1364

However, there are also URLs in the list I am searching that contain uppercase versions of this URL:

http://www.example.com/newsroom/press/release/?id=8A0223BA-AF12-4406-A4A5-AF603C0A1364

or structures like:

http://www.example.com/issues/polls/
http://www.example.com/mystory/?rid=1234&quote=Here I am

I am trying (but not very well) to construct a Regular Expression that will match any URL in my list, but if it contains a GUID only match GUIDs that are comprised of lower case characters.

So, using the examples above these URLs would be OK


http://www.example.com/newsroom/press/release/?id=8a0223ba-af12-4406-a4a5-af603c0a1364
http://www.example.com/issues/polls/
http://www.example.com/mystory/?rid=1234&quote=Here I am

But this one would not match

http://www.example.com/newsroom/press/release/?id=8A0223BA-AF12-4406-A4A5-AF603C0A1364

n.b that the upper case GUID is not always at the end of the string (which is something I made a mistake by placing a $ in at the end).

Does anyone have an idea of how to achieve this if specific string pattern exist, only match if it is lowercase. If it does not exist, then accept string.

Al

$url='http://www.example.com/mystory/?rid=1234&quote=Here I am';
my ($guid) = ($url =~ m/.[^\\?]*r?id=[a-z\\-\\d]*/)

Isn’t this the same as “if the string contains an uppercase GUID reject it, otherwise accept it”?
If it is, I think you’ll know what to do :slight_smile: