如何使用空手道中的包含将字符串列表与子字符串匹配

How to match a list of string with substring using contains in karate

* def response = ["-1302.3000","110992.2204","-3990.6580","-7678.6279","4964.0000","3415.6366"]
* def val = '-1302.3'
Then match response contains "#regex ." + val + ".*"

错误:- 匹配失败:包含 $|不是字符串(列表:字符串) [“-1302.3000”,“110992.2204”,“-3990.6580”,“-7678.6279”,“4964.0000”,“3415.6366”] '#regex .-1302.3.*'

这适用于最新版本的空手道 (1.1.0)

* def response = ["-1302.3000","110992.2204","-3990.6580","-7678.6279","4964.0000","3415.6366"]
* def val = '-1302.3'
* match response contains "#regex " + val + ".*"

话虽如此,请参阅下面的建议:

* def response = ["-1302.3000","110992.2204","-3990.6580","-7678.6279","4964.0000","3415.6366"]
* def numbers = response.map(x => x * 1)
* match numbers contains -1302.3

我把它留作作业,让你了解它是如何工作的。