• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Contributor ,
Oct 09, 2020 Oct 09, 2020

Copy link to clipboard

Copied

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

TOPICS
How to

Views

637

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 09, 2020 Oct 09, 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

 

Votes

Translate

Translate
Contributor ,
Oct 09, 2020 Oct 09, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 09, 2020 Oct 09, 2020

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 09, 2020 Oct 09, 2020

Copy link to clipboard

Copied

LATEST

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines