Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag for United States of America

asked on 

Using RegExp to find all occurrences of a word in a string.

Find all occurrences of a word in a string where the word can be at the start of the string, the end of the string, or anywhere in the middle, and the word must not be part of any other word.

This works outside of Windows:

(?<=^|[^A-Za-z])(Word)(?=[^A-Za-z]|$)

But does not produce any results inside Windows. I think it has something to do with look-behind logic but, when I remove that part, it still fails:

(?=^|[^A-Za-z])(Word)(?=[^A-Za-z]|$)

Kevin
Regular Expressions

Avatar of undefined
Last Comment
zorvek (Kevin Jones)

8/22/2022 - Mon