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

Regex multiline not working with beginning of line #13

Closed
jyapayne opened this issue Jul 12, 2018 · 4 comments · Fixed by #63
Closed

Regex multiline not working with beginning of line #13

jyapayne opened this issue Jul 12, 2018 · 4 comments · Fixed by #63

Comments

@jyapayne
Copy link

jyapayne commented Jul 12, 2018

Awesome work on nim-regex! There is one issue that I'm experiencing but may just be using incorrectly.

@genotrance and I are working on replacing nimgen's nre dependency with your pure Nim solution. However, there is one snag where your library performs something different than I expect.

Given the code:

import regex

var input = """foo
           bar
   baxx
             bazz
"""

echo input.replace(re"(?m)^", "//")

The output is:

//f//o//o//
// // // // // // // // // // // //b//a//r//
// // // //b//a//x//x//
// // // // // // // // // // // // // //b//a//z//z/

But I would expect it to be:

//foo
//           bar
//   baxx
//             bazz

which is what I get if I directly replace import regex with import nre in the above code. Am I misunderstanding how the multiline is working?

@nitely
Copy link
Owner

nitely commented Jul 12, 2018

I know why this occurs, I'll fix it in a couple of hours. It seems nre works as you expect and re never returns (there's an infinite loop). I'm surprise there is no infinite loop here, since this function is based on re 😅 .

@jyapayne
Copy link
Author

@nitely awesome, and thanks :)

@nitely
Copy link
Owner

nitely commented Jul 12, 2018

here is an alternative btw input.replace(re"(.*\n?)", "//$1")

@jyapayne
Copy link
Author

@nitely cool, thanks, that works in the meantime!

nitely added a commit that referenced this issue Apr 16, 2020
@nitely nitely mentioned this issue Apr 16, 2020
nitely added a commit that referenced this issue Apr 22, 2020
zero match fixes, fix #13
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 a pull request may close this issue.

2 participants