Thanks for the finer points. So in [] or a character class|set the only characters that must be escaped are \ (backslash), ^ and -. And hyphen can be un-escaped if its last. I have to research more on word boundaries. I sort of hacked my hashtag solution because the preceding match would gobble up the space character need with the next. Wow, trying to explain RegEx thought is ridiculous. But yah, it is crazy that one line of code can take this long to understand.
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
Thanks for the finer points. So in
[]
or acharacter class|set
the only characters that must be escaped are\
(backslash),^
and-
. And hyphen can be un-escaped if its last. I have to research more on word boundaries. I sort of hacked my hashtag solution because the preceding match would gobble up the space character need with the next. Wow, trying to explain RegEx thought is ridiculous. But yah, it is crazy that one line of code can take this long to understand.You don't need to escape
^
in a character class because it has no ambiguous meaning. Same with$
.