Skip to Main Content

Java and JavaScript in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Regex for Javascript for a String

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
regex101: build, test, and debug regex (0 Bytes)
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
1 comment
321 views