You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for Regex.new at Regex.html has the line:
Regex.new("^a-z+:\s+\w+") # => /^a-z+:\s+\w+/
As does the source code for Regex.initialize in src/regex.cr
That is not correct, because the parsing of string values is not the same as the parsing of Regex values, particularly when it comes to escaped characters like \d.
Also, in Ruby one can use a regexp-value as the first parameter to Regexp.new(), to avoid the extra level of escaping that you'd need when using a string-value for that parameter. Crystal does not allow that, although I do not know if that was intentional. If the user tries:
You might wonder why anyone would bother doing Regexp.new( /patrn/ ) instead of simply using /patrn/, and I must admit I do not know why I started doing that. Maybe it had something to do with the state of ruby back in 2002. But if crystal does intend to not allow that, then maybe the definition for Regex.initialize should be:
The documentation for
Regex.new
at Regex.html has the line:As does the source code for Regex.initialize in src/regex.cr
That is not correct, because the parsing of string values is not the same as the parsing of Regex values, particularly when it comes to escaped characters like
\d
.produces:
(which is what I would expect it to do, of course).
The text was updated successfully, but these errors were encountered: