I’m trying to adapt a Haxe Markdown library ( http://code.google.com/p/mdown/ ) into an official haxelib that works across platforms. I’m running into some weirdness where something works on flash and javascript, but not neko.
See this sample code:
var str = "<p>This is a blockquote</p>";
var out = ~/(^|\n)/g.replace(str, "$1 ");
trace(out);
On Javascript and Flash I get this, as expected:
" <p>This is a blockquote</p>"
On Neko I get this:
" < p > T h i s i s a b l o c k q u o t e < / p > "
I can work around it for now (not use regular expressions) – but can anyone show me at what point this breaking?
Thanks,
Jason
p.s. This might help answer the question: http://haxe.org/doc/cross/regexp#implementation-details
If you use the
mflag to convert it into a multiline regex, you can leave out the newline part. That might help.The relevant part of documentation is right at the beginning of the linked page:
As for why your problem is happening, it would appear that Neko’s regex library is wrongly simplifying your regex to empty, which will match between every charater. You could put a . at the end of the regex and move the space to the front of your replacement string, which might prevent that bug from occurring, and it should be compatible with all the implementations.