opal icon indicating copy to clipboard operation
opal copied to clipboard

ruby start and end of string regex tokens not transpiled

Open patrickkettner opened this issue 7 years ago • 5 comments

\A to mean start of a string, and \Z to mean end of a string are taken as literal escaped capital A and escaped capital Z, rather than being transpiled into their true meanings

patrickkettner avatar Nov 06 '16 06:11 patrickkettner

I think the best approach here would be to warn about possible errors and compile those two (and related) to ^$, at lead while we're still using native js regexps

elia avatar Nov 06 '16 17:11 elia

@patrickkettner @elia master already has this logic - https://github.com/opal/opal/blob/master/lib/opal/nodes/literal.rb#L170

iliabylich avatar Nov 07 '16 14:11 iliabylich

@iliabylich - thanks! any idea why this isn't in 0.10.3? This is also only doing \z and not \Z (which is funny, because I believe $ actually maps to \Z better than \z).

I've also since found that opal is broken on \G

patrickkettner avatar Nov 09 '16 09:11 patrickkettner

why this isn't in 0.10.3?

That's because we backport to the current stable just the minimum, otherwise it would become much less… stable.

That said,\Z should problably map to $ too. And \G should print a warning.

elia avatar Nov 10 '16 01:11 elia

\Z is something like /(?>\r?\n?$)/

hmdne avatar Nov 03 '21 10:11 hmdne