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!
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!