I need to find out if my string matches a part of a regular expression, is it possible? For example, there is a regular expression /^\+7\([0-9]{0,3}\)[0-9]{0,3}-[0-9]{0,2}-[0-9]{0,2}$/ , I need to allow
+7 = true; +7(915) = true; +7(915)A = false; Is it possible to do something like this?

  • If you want to write this into a pattern, there is no point. - nick_n_a
  • Yes, so I do not understand how to turn the process, from which side. Regular entry in the string - this is understandable, but on the contrary - his head broke. Perhaps the idea itself must be differently issued? And how ... - Ilya Bazhinov
  • You have the final condition - the end of the line $. The easiest - put | (logical or) with the end of the line. Those. or (or end of line, and so on. - nick_n_a
  • those. The task is trivial: the person enters the phone, his entered data are compared with the pattern, while the string value looks like a phone - everything is ok, as soon as the entered character does not meet the conditions of the mask - standing - Ilya Bazhinov
  • Those. /^+(7 (...)) and so on. - nick_n_a

0