-1

I am trying to write a java code in selenium webdriver to print some error message on console if it finds some special or alphanumeric characters in phone field, and to print error message if it finds special characters in first name or last name field, I am not getting any method to check for special characters. Please help with some method.

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
  • Google for a regular expression – deHaar Oct 16 '19 at 06:23
  • @deHaar nice reply, yes i have googled first, when i was unable to find any satisfactory reply there then only I thought to ask here. – Ayushi Sharma Oct 16 '19 at 06:27
  • Well, it's good you googled first, but you seem to haven't googled the right way because there are loads of tutorials, examples and so… First hit: [Regular expression for phone numbers](https://regexr.com/3c53v), second hit [a question from here (stackoverflow)](https://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation) – deHaar Oct 16 '19 at 06:29

1 Answers1

0

I believe java.lang.String.contains(CharSequence s) is what you should use.

Ioannis Barakos
  • 1,319
  • 1
  • 11
  • 16