Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Add support for matching word boundaries #10

Closed
wants to merge 1 commit into from

Conversation

mrkishi
Copy link
Contributor

@mrkishi mrkishi commented Oct 17, 2016

Currently, values will trigger replacements in the middle of words (see BUILD vs REBUILDING example in the added test case).

While that may be sometimes desirable, there's no way to use delimiters to match word boundaries, as they are escaped before being added to the regex.

This PR adds support for raw \b characters in the delimiters, and makes [ '\b', '\b' ] their default.

Thoughts?

@Rich-Harris
Copy link
Contributor

Rich-Harris commented Sep 5, 2017

It should be possible to do this with the pureExternalImports option (which I've just realised is undocumented 😬 — details here)

@Rich-Harris
Copy link
Contributor

ah whoops, replying to wrong thread. ignore my last

@Rich-Harris
Copy link
Contributor

This is a good idea, thanks 👍 There were lots of conflicts after the recent round of merges and I thought it best not to treat \b as a special case, so I took a slightly different route in #18. Will close this

@Rich-Harris Rich-Harris closed this Sep 5, 2017
@mrkishi mrkishi deleted the word-boundaries branch September 5, 2017 12:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants