I have some troubles with this small JavaScript code:
var text=\"Z Test Yeah ! Z\"; // With literal syntax, it returns tr
You need to double escape \ characters in string literals, which is why the regex literal is typically preferred.
\
Try:
'Z[\\s\\S]*?Z'
I think it's because you have to escape your backslashes, even when using single quotes. Try this:
new RegExp('Z[\\s\\S]*?Z','g')