I have tried to change this regular expression to case-sensitive with a lot of possible solutions (/[u=|&l=|&dl=|&f=]/i and so on) but I didn’t make it to work as I want to.
u=, &l=, &dl=, and &f= is taken from profile-photos.php?u=edgren&dl=. I use this regular expression to only get the username edgren and identify those other GETs (l, dl, and f) for example;
Looking at <a href="'.url('user/'.$profile).'">'.properize($profile).'</a> '.(isset($_GET['l']) ? 'likes' : (isset($_GET['dl']) ? 'dislikes' : 'favorites')) which prints “Looking at edgrens dislikes” with the URL profile-photos.php?u=edgren&dl=.
The regular expression I have now, prints egren (example at regexpal.com) if the GET is &dl= which is wrong. I want to print the whole username and not the half of it, so to speak.
How can I fix my problem?
Thanks in advance.
You are confusing alternation with character classes. If you want to match one of several strings, use round brackets:
(u=|&l=|&dl=|&f=). Square brackets are for character classes (which have the meaning “match one character if it is one of those specified between these square brackets”).Also
imakes the regex explicitly case-insensitive.