findRegexp does not compile escaped character sequences correctly #1411

Closed
crucialfelix opened this Issue Apr 7, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@crucialfelix
Member

crucialfelix commented Apr 7, 2015

- must be escaped in a regex character set: \-

But I think the regex compiler is not being passed the escape sequence.
It should have parsed docs-syntax-fixes and instead it halted at docs:

"(HEAD, tag: docs-syntax-fixes)".findRegexp("tag: ([a-zA-Z0-9\.\-_]+)")
-> [ [ 7, tag: docs ], [ 12, docs ] ]
"(HEAD, tag: docs-syntax-fixes)".findRegexp("tag: ([^ ]+)")
-> [ [ 7, tag: docs-syntax-fixes) ], [ 12, docs-syntax-fixes) ] ]

@crucialfelix crucialfelix added this to the future milestone Apr 7, 2015

crucialfelix added a commit to crucialfelix/supercollider that referenced this issue Apr 7, 2015

@sofakid

This comment has been minimized.

Show comment
Hide comment
@sofakid

sofakid Apr 12, 2015

You need to double the backslashes.

sofakid commented Apr 12, 2015

You need to double the backslashes.

@crucialfelix

This comment has been minimized.

Show comment
Hide comment
@crucialfelix

crucialfelix Apr 13, 2015

Member

ah ha. that would be a bug in itself. escape should not have to be escaped in order to be used as escape.

Member

crucialfelix commented Apr 13, 2015

ah ha. that would be a bug in itself. escape should not have to be escaped in order to be used as escape.

@jamshark70

This comment has been minimized.

Show comment
Hide comment
@jamshark70

jamshark70 Apr 13, 2015

Contributor

Not a bug. \ serves as an escape character in the regexp language. \ is also an escape character in SC string literals. If you are writing a SC string literal whose value should include a backslash character (serving as a regexp escape), then yes, you need two backslashes.

Contributor

jamshark70 commented Apr 13, 2015

Not a bug. \ serves as an escape character in the regexp language. \ is also an escape character in SC string literals. If you are writing a SC string literal whose value should include a backslash character (serving as a regexp escape), then yes, you need two backslashes.

@crucialfelix

This comment has been minimized.

Show comment
Hide comment
@crucialfelix

crucialfelix Apr 13, 2015

Member

ok, agreed.

I guess that's why python uses the special r string: r"exp."

the r before the string marks it as a special type so its compiled with the
\ still in there

On Mon, Apr 13, 2015 at 4:31 PM jamshark70 notifications@github.com wrote:

Not a bug. \ serves as an escape character in the regexp language. \ is
also an escape character in SC string literals. If you are writing a SC
string literal whose value should include a backslash character (serving as
a regexp escape), then yes, you need two backslashes.


Reply to this email directly or view it on GitHub
#1411 (comment)
.

Member

crucialfelix commented Apr 13, 2015

ok, agreed.

I guess that's why python uses the special r string: r"exp."

the r before the string marks it as a special type so its compiled with the
\ still in there

On Mon, Apr 13, 2015 at 4:31 PM jamshark70 notifications@github.com wrote:

Not a bug. \ serves as an escape character in the regexp language. \ is
also an escape character in SC string literals. If you are writing a SC
string literal whose value should include a backslash character (serving as
a regexp escape), then yes, you need two backslashes.


Reply to this email directly or view it on GitHub
#1411 (comment)
.

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