-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
re.replace("foo", re"", "-") returns -foo, inconsistent with nre.replace #9437
Labels
Comments
Can you please copy the detailed comment here into the issue where it is visible. And please don't use imperative in the issue title, call the problem it present tense. This also applies to your other issues. |
timotheecour
changed the title
Fix the
replace("foo", re"", "-") returns -foo, inconsistent with nre
Oct 29, 2018
replace("foo", re"", "-")
case in re module
timotheecour
changed the title
replace("foo", re"", "-") returns -foo, inconsistent with nre
re.replace("foo", re"", "-") returns -foo, inconsistent with nre.replace
Oct 29, 2018
@krux02 done (@kaushalmodi I took the liberty to edit your post) |
@xflywind thanks for self-assigning this; maybe also define |
ringabout
added a commit
to ringabout/Nim
that referenced
this issue
Mar 28, 2021
PMunch
pushed a commit
to PMunch/Nim
that referenced
this issue
Mar 28, 2022
* fix nim js cmp fails at CT * fix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Detailed comment: #9315 (comment)
/cc @skilchen
EDIT by @timotheecour
"-f-o-o-"
"-f-o-o-"
"-f-o-o-"
copying over the comment from @skilchen :
produces:
-foo
While in the common understanding of regular expressions there is an empty string in front of any string, one between every substring of length 1 and one at the end of the string.
nre.nim produces the usually expected -f-o-o-
With nre as well as in the other languages I know the following is also possible:
which produces
-foo-
as expected, but using re you get: -foo which doesn't seem correct.
still produces an empty line, which doesn't seem correct, I would expect - -. However on a string that usually should be split using this pattern, it works:
correctly produces:
abc - 123 - ###
further discussion
@Araq said:
if we're departing from other regex engines, an option could be to throw ; but at least it'd be nice to have consistent behavior across re,nre,nim-regex
The text was updated successfully, but these errors were encountered: