Servoy 4 uses a newer version of Rhino, 1.6 if I’m correct. The new version has several fixes voor regular expressions and that probably made the difference in your case.
What exactly are you trying to match here? Strings starting with “Z"?
The problem is that "” is a special character meaning “zero or more occurences”. If you want to match “*” literally, it needs to be escaped with a single backslash, so in your case:
Joas:
Servoy 4 uses a newer version of Rhino, 1.6 if I’m correct. The new version has several fixes voor regular expressions and that probably made the difference in your case.
It seems so …
Joas:
What exactly are you trying to match here? Strings starting with “*Z”?
Exactly.
Joas:
The problem is that “" is a special character meaning “zero or more occurences”. If you want to match "” literally, it needs to be escaped with a single backslash, so in your case:
source.match(/^\*Z/)
Yes I know, but these strings are given from the timetable. What’s the meaning of the first and last slash in your argument in match()? I did it without them but then I need the 2 backslashes as seen above in my example to match the *Z pattern, but it’s sort of strange I think and can’t explain it to myself.
Robert Huber:
What’s the meaning of the first and last slash in your argument in match()?
That’s the JS notation of a regular expression.
You can use var r = new RegExp(“my expression”) or you use var r = /my expression/
For further reading check http://www.regular-expressions.info/javascript.html