-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Duplicated backslashes in regular expressions #536
Comments
Btw if someone runs into the same issue, a temporary fix is: import format from 'date-fns/format';
import enLocale from 'date-fns/locale/en';
(() => {
console.log(format(new Date(), 'GGGG-[W]WW', {
locale: {
format: {
formatters: enLocale.format.formatters,
formattingTokensRegExp: /(\[[^\[]*\])|(\\)?(x|ss|s|mm|m|hh|h|do|dddd|ddd|dd|d|aa|a|ZZ|Z|YYYY|YY|X|Wo|WW|W|SSS|SS|S|Qo|Q|Mo|MMMM|MMM|MM|M|HH|H|GGGG|GG|E|Do|DDDo|DDDD|DDD|DD|D|A|.)/g
}
}
}));
})(); |
Also by the way the expected output of the |
PepijnSenders
changed the title
Backslashes Regex problem
Duplicated backslashes in regular expressions
May 17, 2017
This issue was already fixed in master. This is the output code on master branch var formattingTokensRegExp = new RegExp('([[^[]*])|(\\)?(' + formattingTokens.join('|') + '|.)', 'g'); PR - #490 |
Thanks! Do you know when this will be released? |
We are doing some cleanups in the new CLI, pretty soon. |
Closing this as it is fixed in master. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found this issue while trying to get the
babili-webpack-plugin
to work with date-fns.The issue is the following, when using the
date-fns/format
function the formatting regular expression will get messed up.This code:
Will become:
As you can probably see this will result in too many slashes and subsequently break the
date-fns/format
function.Wondering if anyone else found this issue before and if it's something persistent if someone could fix it.
For testing this was my
.babelrc
:My
webpack.config.js
:And the file to compile:
The text was updated successfully, but these errors were encountered: