The problem is that [ \t]
is not an equivalent for \h
:
[ \t]
covers exactly two whitespace characters (U+0020 and U+0009), where \h
covers two dozens of them or more.
For a nice and readable list of whitespace characters see the Wikipedia article.
Of course, most of them are rarely used, but the following characters you will find in texts:
U+00A0 no-break space
and to lesser degree:
U+2009 thin space
U+202F narrow no-break space
U+200A hair space
Those characters are directly accessible in common programs like Adobe Indesign:
…and of course also in TeX-based typesetting systems (ConTeXt, LaTeX) and other. And they are used (not only by me ;)).
So, to cover also those characters, there are (at least) two good replacements for \h
that should work also with programs/languages that are not (yet) supporting \h
:
[[:blank:]]
That is the POSIX expression for \h
. (As you know, I don't have the faintest clue of JavaScript, so you have to test it yourself if it works with JS.)
If the POSIX expression doesn't work, then this should work:
[^\S\r\n]
Both are not 100% equivalent to \h
but they should do the trick with most texts. In any case they are more comprehensive than [ \t]
.
‌
This StackOverflow post is worth reading: