-2

I have tried to match <b> using regular expressions.

the pattern /<.>/ matches <b> but the pattern /<[.]>/ does not match.

What is the difference between /<.>/ and /<[.]>/ in regular expressions

1 Answers1

0

When you put dot inside [] it is a literal dot, not a any character. So the /<[.]>/ matches only <.>. It is the same as escaping a dot: \. in regexp.

Krzysztof Krasoń
  • 23,505
  • 14
  • 77
  • 102