I'm trying to match entire strings that:
- Only has one occurrence of the specified word
- Allows anything before and after the occurrence, except specified word
The ideal results are as such:
{{REPLACE}}. // Valid
{{REPLACE}} {{REPLACE}}. // Invalid
{{REPLACE}}{{REPLACE}}. // Invalid
Text here {{REPLACE}}. More text here. // Valid
{{REPLACE}} text here {{REPLACE}}. More text here // Invalid
The closest I've gotten to is
{{REPLACE}}. // Valid
{{REPLACE}} {{REPLACE}}. // Valid
{{REPLACE}}{{REPLACE}}. // Invalid
Text here {{REPLACE}}. More text here. // Valid
{{REPLACE}} text here {{REPLACE}}. More text here // Valid
Using /(?<!({{REPLACE}}))({{REPLACE}}){1}(?!({{REPLACE}}))/