Allow regex expression to include special characters and spaces

I have this regex expression _ (\w+),(\w+)-(\d{4}) _ it reads any word character before and after the comma and then 4 digits after a dash. I am using this for names for example: _ lastname,Firstname-XXXX _ . This does not work if a name has a dash in it or apostrophe or if there is a two-name first name with spaces. for example a name like this doesn’t work _ david-johnson,Juan Jose-0000 _ I need the regex to pick up every character and include the spaces as well.

Please check if this helps:


To only account for dashes and spaces in addition to word strings, use the regex below:

_ (\w+( *-* *\w*)*),(\w+( *-* *\w*)*)-(\d{4}) _

How would I allow apostrophe in this as well, for last and first name?

_ (\w+( *-* *'* *\w*)*),(\w+( *-* *'* *\w*)*)-(\d{4}) _

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.