When parsing a Regexp in extended mode, the documentation states:
Modifier x enables extended mode, which means that:
- Literal white space in the pattern is to be ignored.
- Character # marks the remainder of its containing line as a comment,
which is also to be ignored for matching purposes.
The following Regexp in extended mode doesn't not exactly do what I imagined:
/
test # the following slash / should be ignored
/x
My interpretation of the documentation is that anything after # is ignored. However, the / is not ignored, leading to the following error message:
-: -:2: syntax errors found (SyntaxError)
1 | /
> 2 | test # the following slash / should be ignored
| ^~~~~~ unexpected local variable or method, expecting end-of-input
> 3 | /x
| ^ unterminated regexp meets end of file; expected a closing delimiter
Note that using the old parse.y implementation also leads to an error:
-:2: syntax error, unexpected local variable or method, expecting end-of-input
... # the following slash / should be ignored
-: compile error (SyntaxError)
So is this a parsing error or a documentation error?
When parsing a Regexp in extended mode, the documentation states:
The following Regexp in extended mode doesn't not exactly do what I imagined:
My interpretation of the documentation is that anything after
#is ignored. However, the/is not ignored, leading to the following error message:Note that using the old parse.y implementation also leads to an error:
So is this a parsing error or a documentation error?