Regexp in Java
I want to make a regexp who do this
verify if a word is like [0-9A-Za-z][._-‘][0-9A-Za-z]
example for valid words
A21a_c32
daA.da2
das'2
dsada
ASDA
12SA89
non valid words
dsa#da2
34$
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
^[0-9A-Za-z]+[._'-]?[0-9A-Za-z]+$(see matches on rubular.com)Key points:
^is the start of the string anchor$is the end of string anchor+is “one-or-more repetition of”?is “zero-or-one repetition of” (i.e. “optional”)-in a character class definition is special (range definition)….unescaped outside of a character class definition is special…References