1

I want to check whether the values in array match regex using 'karate.match' But I'm getting polyglot exception because I have brackets in my regex, any idea how to fix this issue?

* def result= karate.match("each valueData == '#regex ^\'[A-Z0-9]+([\']?[,]?[\']?[A-Z0-9]+)*\'$'")
* match result == { pass:true, message:null }
* print result
org.graalvm.polyglot.PolyglotException: SyntaxError: Unnamed:1:41 Expected an operand but found )
'#regex ^'[A-Z0-9]+([']?[,]?[']?[A-Z0-9]+)*'$'
                                         ^
  • Text I want to match using regex can be, 'AAQS700CM' or 'AAQS700CM','AERS700CM','BCNS700CM' – user14719581 Sep 28 '22 at 09:36
  • I'll pass, personally I think this is an over-complicated assertion, maybe you should just use a JS function like seen here: https://stackoverflow.com/a/65036047/143475 – Peter Thomas Sep 28 '22 at 18:08

0 Answers0