Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern doesn't match with trailing whitespace #309

Open
picobots opened this issue Oct 28, 2023 · 0 comments
Open

Pattern doesn't match with trailing whitespace #309

picobots opened this issue Oct 28, 2023 · 0 comments

Comments

@picobots
Copy link

Given the following CSS:

body {
  margin: 0;
}

If I include a trailing space at the end of my regular expression pattern, postcss-replace will not perform the replacement. For example, this postcss-replace config does not work (note the space character after the word "body") :

// This does not work
postcssReplace({
  pattern: /body /g,
  data: { replaceAll: "BLAH " }
}),

But if I remove the trailing space, then the replacement works correctly:

// This works correctly
postcssReplace({
  pattern: /body/g,
  data: { replaceAll: "BLAH" }
}),

Any idea what's happening here? According to this test on RegExr, a trailing space should correctly match in this scenario. I've tried using \s to match any whitespace character and that does not work either. Something odd seems to be going on with whitespace at the end of the regular expression pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant