Skip to Main Content

Regex expression

user5108636Jul 26 2021

Need to create a regex for a string with below criteria
Allowable characters:
uppercase A to Z
lowercase a to z
hyphen
apostrophe
single quote
space
full stop
numerals 0 to 9

Validations:
Must contain alphabetic characters
Cannot have consecutive non alpha characters except for full stop followed by a space
Cannot have non-alphabetic characters at the start
I am using the below site to test the regex in ECMAScript Javascript
card.pngregex101: build, test, and debug regex
https://regex101.com
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO,…

The regex I created
^(?!.*[0-9'`\.\s-]{2})[a-zA-Z][a-zA-Z0-9-`'.\s]+$
Not sure how to put an exception to allow a fullstop followed by a space. Please advise.

Comments
Post Details
Added on Jul 26 2021
0 comments
16 views