Hi all.
I need to recognize some special keywords in my app. I usually accomplish this task with a regex construction like this…
…that means “match the keyword if it is preceded and succeeded by a non-alphanumeric character only”.
This time I need to NOT allow a keyword to be matched if it is preceded or succeeded by a $ character, but unfortunately the damned regex engine considers the $ a non-alphanumeric character, so the above construction doesn’t work. I found the next regex construction as a workaround for my problem…
…but it is a more complex, hard to understand and maybe slower construction than the original one that uses the \b escape for word boundaries.
Is there any way I can modify the alphanumeric \w and non-alphanumeric \W classes so I can make the $ character an alphanumeric one and then keep using the stylish \b escape for my needs?
Thanks in advance.
I need to recognize some special keywords in my app. I usually accomplish this task with a regex construction like this…
Code:
\bkeyword\b
This time I need to NOT allow a keyword to be matched if it is preceded or succeeded by a $ character, but unfortunately the damned regex engine considers the $ a non-alphanumeric character, so the above construction doesn’t work. I found the next regex construction as a workaround for my problem…
Code:
([\W-[\$]]|\A)keyword([\W-[\$]]|\z)
Is there any way I can modify the alphanumeric \w and non-alphanumeric \W classes so I can make the $ character an alphanumeric one and then keep using the stylish \b escape for my needs?
Thanks in advance.