I am very close to solving this thanks to this post Regex find word in the string
But I am still not 100% there.
If I use this regex along with Apache's BrowserMatchNoCase
^(.*?)(\b360Spider\b)(.*)$
I get the following results:
- 360Spider = match
- 360spider = match
- 360SpIdEr = match
- 360spiders = no match
- Not360Spider = no match
- Not-360Spider = match
- Not-360spider = match
I need it to match the word 360Spider regardless of what is put in front or after the word, so NOT360Spider should be a match.
Thanks in advance, my regex has improved somewhat over the years but I am still nowhere close to fully understanding getting things perfect without leading to false positives.
At the same time I do not want to introduce other false positives which is why I am delving into this in the first place so other user-agent names likes "Exabot" and "Alexabot" I don't want the "exabot" part of Alexabot to be detected.
So let's say in another example:
^(.*?)(\bExabot\b)(.*)$
I get the following results:
- Alexabot = no match
- Exabot = match
- exAbot = match
If I remove word boundaries "\b" as follows:
^(.*?)(Exabot)(.*)$
I get the following results:
- Alexabot = match
- Exabot = match
- exAbot = match
- anythingExabot = match
So I guess I have to stick with the word boundaries "\b" now the trick is to get printf to write the "\b" into my string and not see it as a backspace character.