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

Add multiline support for Regex #644

Closed
lorenzo opened this Issue Jun 12, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@lorenzo
Contributor

lorenzo commented Jun 12, 2016

Currently there seems to be no way of matching a multiline string using a Regex, due to the inability of passing the m flag the the regular expression constructor. A possible solution to this could be to add new multiLine : Regex -> Regex function similar to caseInsensitive.

If there is any interest in this I can help with the implementation

@evancz evancz referenced this issue Sep 22, 2016

Closed

Regex #722

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Sep 22, 2016

Member

Consolidated regex stuff in #722. Follow along there!

Member

evancz commented Sep 22, 2016

Consolidated regex stuff in #722. Follow along there!

@evancz evancz closed this Sep 22, 2016

@Positive07

This comment has been minimized.

Show comment
Hide comment
@Positive07

Positive07 Dec 3, 2016

One issue with this approach is that if you first specify that the Regex should be caseInsensitive and then you want to make it multiLine the current code overwrites the flags. To fix this you would need to get the flags and add the new flags. The problem with that is that flags can't be repeated or the Regex becomes invalid.

I think we need a more generic way of setting and getting flags. Maybe this could be another parameter when creating a Regex, or two separate functions.

There are a few flags available for Regex (g, i, m, y) and all of them can be on at the same time, but as I said they can't be repeated.

So a way to specify and get the flags would be better than having a multiLine, caseInsensitive, ... methods. And also if more Regex flags are added they could be easily added to Elm

Positive07 commented Dec 3, 2016

One issue with this approach is that if you first specify that the Regex should be caseInsensitive and then you want to make it multiLine the current code overwrites the flags. To fix this you would need to get the flags and add the new flags. The problem with that is that flags can't be repeated or the Regex becomes invalid.

I think we need a more generic way of setting and getting flags. Maybe this could be another parameter when creating a Regex, or two separate functions.

There are a few flags available for Regex (g, i, m, y) and all of them can be on at the same time, but as I said they can't be repeated.

So a way to specify and get the flags would be better than having a multiLine, caseInsensitive, ... methods. And also if more Regex flags are added they could be easily added to Elm

@mgold

This comment has been minimized.

Show comment
Hide comment
@mgold

mgold Dec 3, 2016

Contributor

Perhaps: Regex.withFlags { g = False, i = True, m = False, y = False } "turtles( on turtles)+"

Contributor

mgold commented Dec 3, 2016

Perhaps: Regex.withFlags { g = False, i = True, m = False, y = False } "turtles( on turtles)+"

@Positive07

This comment has been minimized.

Show comment
Hide comment
@Positive07

Positive07 Dec 3, 2016

Yes something like that, I thought about Sets first but a Hash may work too.

I would love to have a RegexFlags type or type alias, Regex.getFlags: Regex -> RegexFlags and Regex.setFlags: RegexFlags -> Regex too.

Positive07 commented Dec 3, 2016

Yes something like that, I thought about Sets first but a Hash may work too.

I would love to have a RegexFlags type or type alias, Regex.getFlags: Regex -> RegexFlags and Regex.setFlags: RegexFlags -> Regex too.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Dec 12, 2016

Member

I really like that @mgold, cool idea! Not sure when to make a change like that, but I like it.

Member

evancz commented Dec 12, 2016

I really like that @mgold, cool idea! Not sure when to make a change like that, but I like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment