Forum Stats

  • 3,757,812 Users
  • 2,251,271 Discussions
  • 7,869,922 Comments

Discussions

Regex expression

user5108636
user5108636 Member Posts: 1,744 Silver Badge

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

regex101: 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.