RegEx

Joined
Sep 1, 2022
Messages
1
Reaction score
0
Hello all, having some problems with RegEx, I tried a couple of combinations, but I can't seem to make the preceding requirement.

Requirements are as follows:
The variable should only consist of case-in-sensitive alphabet characters and may include character spaces and/or hyphens. The hyphen symbol should only be preceded by one or more alphabet characters and not appear as the first or the last character.

So far, this is what I have attempted:

/^[a-zA-Z]+(?<=\w)\-[\a-zA-Z ]*[A-Za-z]+$/

Cases like this won't work: Example A-User. I attempted to use a positive look behind to ensure that the hyphen should have words in front, but the case I provided will not work since there is a space.
Not exactly sure how to proceed here; any help and explanation will be appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top