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'