Regular expression to detect keywords ERP and C# and C++?

I want to detect several keywords as whole words within a string, through Regex pattern.
I started with the keyword ERP, by simply using the following pattern: \bERP\b
But this won’t work with the keyword C#, meaning that I’m unable to find C# using the pattern \bC#\b In the same way, I’m also unable to find \bC++\b as a whole word.
And \bERP\b doesn’t find the following string: ERP6
And I would like for it be detected.
Can someone help me out with a regular expression for detecting only whole words, and entering into account with the above mentioned issues?
Thanks in advance!

Taking the following test string into account: regex101: build, test, and debug regex , I would like only the following keywords to be detected:

erp
ERP
c++
C#
C++
erp6

Only whole words. No substrings. Meaning that I don’t want “erp” to be detected within the word “PowerPoint”.

Hi @jcab,

Pattern: ([Cc]\+\+)
Pattern: ([Cc]\#)
Pattern: ([EeRrPp])
Pattern: ([erp6])

Regards,
Arivu

To find all the keywords in single regex pattern???

Regards,
Arivu

Yes, to find everything in a single pattern.

This is related to the following topic: Regex expression to match a keyword within a string, delimited by spaces, comas and semicolons - #4 by arivu96

I have an Excel file with a lot of keywords. These keywords may be for example: ERP, SQP, c++, c#.
The keywords are read from the Excel file into the variable “keyword”.
I then search the variable keyword in a given big string. And only whole words shall be matched. Meaning that “erp” shall not be matched in the string “PowerPoint”.

So initially i used the regex pattern “\b”+keyword+“\b”. And it seemed to work good. But in the end it didn’t match c# or c++ or ERP6.
That’s the reason I’m trying to find some help to detect this in a single pattern :slight_smile:

Hi @jcab,
Try this pattern
(([Cc]\+\+)|[EeRrPp][6]?|([Cc]\#))

Regards,
Arivu

Sorry, it does not work.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.