Skip to main content
Known Participant
October 9, 2020
Answered

How do you match a hash character "#" in GREP?

  • October 9, 2020
  • 2 replies
  • 1342 views

How do you match a hash character "#" in GREP? If I enter the symbol directly it is not seen as an ordinary character. I have tried with quotes and with a backslash as an escape, but to no avail.

 

Jason

This topic has been closed for replies.
Correct answer Manan Joshi

I think the issue is with the use of \b, it will look for position after # and hence it won't match. Try something like the following

\b(return|function)\b|#include\b

-Manan

 

2 replies

Manan JoshiCommunity ExpertCorrect answer
Community Expert
October 9, 2020

I think the issue is with the use of \b, it will look for position after # and hence it won't match. Try something like the following

\b(return|function)\b|#include\b

-Manan

 

-Manan
Known Participant
October 9, 2020

Thanks

Known Participant
October 9, 2020

Here is basically what I have so far:

\b(return|#include|function)\b

This will match the strings return and function, but not the string #include.