Javascript string.split() fails with special character

Hi all,

any idea why this fails if I put it inside a rule?
take a look at the special character (round open bracket)

var String callerNameStripped = callerName.split("(").get(0)

Error: Unclosed group near index 1

while this works?

var posSplit = callerName.indexOf("(")

Stefan

Hi Stefan,

it should not fail because of the bracket. I think it fails because of “var String callerNameStripped”.

try only this (without string):

var callerNameStripped = callerName.split("(").get(0)
1 Like

It thinks the ( is part of a regex. Escape the ( with a \ or maybe \\.

Thanks for offering help. Unfortunately both doesn’t lead to success.

If a remove the “String” word, nothing changes.
Btw: I think the error message is clear “unclosed group”, so it’s expecting another round closing bracket :-/

It I try to escape the error turns into:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )

Btw: I tried already to create a string variable to save the seperator, like var seperator="(", but then the “unclosed group” error still occurs. Then I tried to use regex (although I have no clue if I am doing it right), still no success.

Maybe a bug?

Stefan

Did you try “\\(”

That’s it!!! Thanks mate

1 Like