空手道-有一种方法可以在字符串正则表达式中使用变量 [英] Karate - Is there a way where I can use a variable in string regex
本文介绍了空手道-有一种方法可以在字符串正则表达式中使用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
空手道-有一种方法可以在字符串正则表达式中使用变量.类似于以下内容
Karate - Is there a way where I can use a variable in string regex. Something similar as below
match each productCodes == "#regex (?i).*+codes+.*"
任何替代或最佳做法将不胜感激.我正在尝试从响应中获取一个字符串数组,以进行每次匹配(一次给我一个字符串),并与来自另一个调用的字符串变量进行比较.
Any alternative or best practice would be appreciated. I am trying to get an string array from response for doing a match each (which gives me a string at a time) and compare to a string variable coming from another call.
推荐答案
示例代码:
Feature: Regex Match
Scenario:
* def act = ["abcd","bcde","cdef","defg"]
* def exp = "c"
* match each act == ('#regex (?i).*' + exp +'.*')
相关链接: https://github.com/intuit/karate/blob/master/README.md#enclosed-javascript
这篇关于空手道-有一种方法可以在字符串正则表达式中使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文