isMatch returns always false on a given regex

Hi guys, I would like to apply a Regex on my string variable. I`m using the isMatch function for that in an IF statement. The problem that i face is that the isMatch returns always false.  This is my code line on the IF statement isMatch($UserEmail,'[A-Z]'), even though i`ve tried to write it in this format isMatch($UserEmail, '^([A-Z]+)$') and still returns false. The $UserEmail is in string format like (What I’m trying to do is to find at least one upper character in the whole email address) Many thanks.
4 answers

isMatch implicitly adds ^ in front of your regex and $ at the end. So don’t include them since this would result in a regex like ^^[A-Z]$$ thus not finding anything. And [A-Z] always results in false since is does not include @ nore .

Search on  [a-zA-Z]*@*.*

Or for a more extensive test: isMatch($mail, ‘[a-z0-9!#$%&''*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&''*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?’)

Or try isMatch at

3 is my best friend in these situations


The CommunityCommons module also contains the Rule EmailAddressRegex which you can use as a not too restrictive regex. 


Hi Norbert,

When checking e-mail addresses using regex I always like to keep it simple, as you need a very complex one to properly validate all valid e-mail addresss, which can get pretty complex. The following regex simply checks for the string to adhere to the following structure: (some text but no ‘@’) + @ + (some text but no ‘@’) + . + (some text but no ‘@’)

isMatch($YourObject/emailAddress, '^[^@]+@[^@]+\.[^@]+$')


If your question was not so much e-mail related but more regex related then just ignore my comment :)

EDIT: ah I didn’t notice your ‘Capital’ requirement, my bad