[Answered ]-Regex matching alphanumeric with special characters

2👍

Your current RegEx will match:

  • A string of one or more letters, numbers and/or underscores: [A-Za-z0-9_]+

OR

  • A SINGLE character that is NOT a letter, number or underscore. [^A-Za-z0-9_]

You probably need something more like:

(?P<bu>[\w-]+)

This will match letters, numbers, underscore and hyphens. Add any other special characters you want as well (inside the square brackets). Remeber certain characters need escaping with \ before them.

0👍

Try this-

/^(?=.[a-z])(?=.[A-Z])(?=.\d)(?=.(_|[^\w])).+$/

👤Dev1ce

Leave a comment