Skip to content

add dotAll regexp flag #133

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

Merged
merged 1 commit into from
Dec 23, 2020

Conversation

fujisawa
Copy link
Contributor

This flag is useful especially when it's used with replace function. Let's say we have a big string that contains html and we want to extract the title from it. If we have dotAll regexp flag, we can write the code like this:

replace (unsafeRegex "^.*<title>([^<]+)</title>.*$" dotAll) "$1" bigString
It's quite quick and simple. With this, we can remove unneeded parts over multiple lines. This flag is supported by ES2018 and currently, node.js and browsers other than Internet Explorer and Firefox for Android cover that.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll

Copy link
Member

@kl0tl kl0tl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support for this flag is almost on par with the unicode and sticky flags that we already have (see https://kangax.github.io/compat-table/es2016plus/#test-s_(dotAll)_flag_for_regular_expressions and https://kangax.github.io/compat-table/es6/#test-RegExp_y_and_u_flags), so albeit this is an ES2018 feature I think we can merge this.

@thomashoneyman thomashoneyman merged commit 3de404e into purescript:master Dec 23, 2020
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

Successfully merging this pull request may close these issues.

3 participants