I have text like this (1 or 0 tab + multiple whitespaces at line beginning):
(tab) There are a tab and 4 whitespaces before me. // line 1
(tab) There are a tab and 6 whitespaces before me. // line 2
There are 6 whitespaces before me. // line 3
There are 4 whitespaces before me. // line 4
When i use ^[\t\s]\s*, only line 1,2 are matched, line 3, 4 are not matched, why?
(When i use ^\s*, line 3 and 4 can be matched.)
Thanks!
That is interesting. I’m not sure why the
\sdoesn’t work inside of[]brackets. Perhaps it is because[]defines explicit characters and\sis ambiguous (it can stand for multiple characters). In other words\sstands for any whitespace, including a tab(\t). However, if you explicitly specify a space in this case (^[\t ]\s*) it will work.