423,822 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,822 IT Pros & Developers. It's quick & easy.

Purpose of '#' character in regular expressions

P: 3

Quick question here, and wondering if anyone can help. I often see the hash character ('#') in regular expressions and am wondering what purpose it is supposed to serve.


Every bit of online documentation I have looked at states the hash character's purpose is merely to denote the line is a comment. Clearly this is not the case if the regular expression is actually being used to test for something.

Can anyone help?
Oct 7 '07 #1
Share this Question
Share on Google+
5 Replies

P: 3
Just bumping here...hope that's OK. Again, any response will be very much appreciated.
Oct 10 '07 #2

code green
Expert 100+
P: 1,726
I don't think it has any syntax value, but then again I am terrifiied of regular expressions.
Are you looking at examples where the hash is part of the pattern to be found by any chance.
Oct 10 '07 #3

P: 3
Thanks for the response. Nope, the hash just seems to be part of the furniture, so to speak. Some end in #si, for example, denoting it's a regex construction thing.

Any more ideas from anyone?
Oct 14 '07 #4

P: n/a
The hash character (i.e. '#') at the beginning and end is the indicator for the beginning and end of the regex pattern.
Oct 18 '10 #5

P: 1
Patterns used in PHP PCRE (Perl Compatible Regular Expressions) must be surrounded by a delimiter, which can be non-alphanumeric, non-backslash, non-whitespace character. When you see the hash character at the start of the regex, it is because that particular developer chose it as the delimiter. You should see a hash at the end of the regex as well.

Source: http://php.net/manual/en/regexp.refe...delimiters.php
May 8 '18 #6

Post your reply

Sign in to post your reply or Sign up for a free account.