6

I have this regex: [\s\S-[<>]]*

Could you please help me understand what does this expression stand for? From what I see it means a character class formed of spaces and a range from non-space characters to < or >?

It doesn't make much sense..

Thanks!

Tim
  • 13,264
  • 9
  • 61
  • 98
Dan L.
  • 1,665
  • 1
  • 19
  • 39

1 Answers1

10

This is a variant only supported by a few regex engines (.NET, JGSoft, XML Schema and XPath but not for example native Java regex), and it's called character class substraction.

For example,

[A-Z-[EFG]]

matches any letter from A to Z except E, F or G.

But in your case, it really doesn't make much sense because [\s\S] matches any character - the same result (in any regex flavor) can be achieved by

[^<>]*
Tim Pietzcker
  • 297,146
  • 54
  • 452
  • 522