I'm having a conundrum with a regexp for an HTML background-color attribute. The IDE I'm using highlight's the '#' and subsequent characters as comments. I've tried escaping the hash symbol, to no avail.
While I'm sure you appreciate all of the helpful coding/commenting tips provided by our fellow monks, i noticed most of them don't really seem to have paid very much attention to your specific question.
In general, you don't need to escape a "#" character you use in a regexp, unless you really want to -- I tend to use "\#" so that my emacs syntax highlighting makes more sense.
If however your IDEs syntax highlighting isn't that smart, you can allways try writting the # symbol as hex: "\x23", so that your IDE never even notices that it's a comment...
box:~> perl -le 'print "yes" if shift =~ "a\x23b";' aaa#bcd yes
In reply to Re: Escaping '#' in a regexp
by hossman
in thread Escaping '#' in a regexp
by Tricky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |