How to set word boundary using regex?
aldrinrenzcruz opened this issue · comments
Aldrin Renz Cruz commented
Please help.
In
highlight: 'title',
className: 'red'
I tried adding a /\btitle\b/g but it's not working and I'm not sure how to customize the library.
How can I add a word boundary for title so that it won't highlight "subtitle" or any other word with "title" in it?
code913 commented
You could just put a \s
around the word title
Aldrin Renz Cruz commented
Please tell me how? I tried \stitle\s
but it's not working?
code913 commented
nvm that was wrong
You could use lookaround: (?<=\b)title(?=\b)
Aldrin Renz Cruz commented
Sorry this is still not working for me. Is this applicable to what I'm using which is inside quotation marks?
highlight: '(?<=\b)title(?=\b)',
className: 'red'
So something like that?
But thank you for trying to help me, really appreciate it!