Answer the question
In order to leave comments, you need to log in
How to check if a string only consists of certain characters?
I need to do 3 checks:
Answer the question
In order to leave comments, you need to log in
It can be implemented with regular expressions.
Here you can test them: https://regex101.com/
For example: "1. the string consists only of letters and the following characters: space and hyphen"
Regular: [a-zA-Z\-\s]
Test string: sdlfkj -sdfgklj ifds
By trial and error, you will recover in 6-8 hours.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question