I am using a regex in java script to validate a full name field. I need the validation to accept 1 or more instances for any [a-z A-Z] characters and also the field MUST include a - and a space character.
The current regex i am using is : ("^[a-zA-Z\\-\\\s]*$");
This regex is allowing the correct input for what i want, however, it does not force the user to insert a space and a - which i need my validation to include. I am very new to regex and was only introduced to them yesterday so i do not fully understand the correct use of certain characters.
I also do not want the space and - to be at the start or end of the field and not directly next to each other.
examples of valid input:
John smi-th
dereK al-jamone
ro-binstanle y
I know this validation is unusual but I would be very grateful for any help to enable me to get a better understanding of regex.