[Resolved] Multiple RegEx Function
I'm having a little trouble putting together a clean function to check for multiple RegEx possibilities. I will be reading some text into a variable and need to check if it contains any of the patterns, if so return True. My way is getting a big long and messy. Can someone post a short condensed way of doing it? I will be adding more RegEx patterns later but the 3 below are what I got so far.
'1-555-555-5555
re.Pattern = "^1?\s*-?\s*(\d{3}|\(\s*\d{3}\s*\))\s*-?\s*\d{3}\s*-?\s*\d{4}$"
'555-555-5555
re.Pattern = "^[2-9]\d{2}-\d{3}-\d{4}$"
'555-5555
re.Pattern = "\d{3}-\d{4}$"
Eidt: Nevermind, I just realized the last RegEx pattern would work for all of themso no need to test the others. Lol sorry didn't think it through.
Re: Multiple RegEx Function
I don't understand how you are doing it so far. What is 're'?
Re: Multiple RegEx Function
Quote:
Originally Posted by Hack
I don't understand how you are doing it so far. What is 're'?
Opps sorry, it's Dim re As New RegExp