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

精读《正则 ES2018》 #127

Closed
ascoders opened this issue Feb 11, 2019 · 2 comments
Closed

精读《正则 ES2018》 #127

ascoders opened this issue Feb 11, 2019 · 2 comments

Comments

@ascoders
Copy link
Owner

ascoders commented Feb 11, 2019

ES2018 推出了正则表达式的第九版规范,让 JS 正则功能更强大,也更易读了!

原文:New JavaScript Features That Will Change How You Write Regex

一起了解让人激动的新特性吧!

const re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/;
const [match, year, month, day] = re.exec('2020-03-04');

console.log(match);    // → 2020-03-04
console.log(year);     // → 2020
console.log(month);    // → 03
console.log(day);      // → 04

精读《正则 ES2018》

@muzea
Copy link

muzea commented Feb 11, 2019

断言支持逆向环视让人印象深刻,edge上面整个app直接崩溃了。。。

@ascoders
Copy link
Owner Author

毕竟 Edge 还不支持,不过 app 崩掉有点厉害了,说明正则执行的风险比较高。

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

2 participants