Bug filed on your behalf. https://bugs.openjdk.java.net/browse/JDK-8172353 <https://bugs.openjdk.java.net/browse/JDK-8172353>
— Jim > On Jan 6, 2017, at 7:27 AM, Esben Andreasen <es...@esbena.dk> wrote: > > Hi > > I stumbled upon a minor discrepancy between Nashorn and other > JavaScript engines when doing regexp matching with the multiline flag > enabled. > > Nashorn > ``` > $ jjs -version > nashorn 1.8.0_111 > jjs> String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); > *a > *c > ** > *e > ``` > > Notice that the characters 'b' and 'd' are gone from the output. > > Node: > ``` > $ node --version > v5.5.0 > $ node >> String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); > '*a\n*b\r*c\n*\r*d\r*\n*e' > ``` > > Firefox & Chrome console: > ``` >> String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); > "*a > *b > *c > * > *d > * > *e" > ``` > > Notice that the characters 'b' and 'd' are in the output. > > - > > I suspect the cause is that nashorn does treat the character after > '\r' as being at the start of a line. > > - > Esben