1

我有一个我无法解决的问题。我愿意根据变量使用正则表达式捕获模式,并且我想获得最短的匹配(不是第一次匹配,但最后一次也是最短的)

这是加特林伪代码

val rubriquesPath=Seq("toto","tata","titi","tutu")

.foreach(rubriquesPath,"rubrique"){
    exec(http("${rubrique}")
        .get("/" + "${rubrique}")
        .check(regex("""URLPage":"(.+?)".*?"path":"/${rubrique}/""").saveAs("tms")))
    .exec(http("TMS " + "${rubrique}")
        .get("${tms}"))
}

数据样本(实际上是单行)

{"displayName":"Bienvenue","URLPage":"preprod.test.com/page/ac73b/4579.json?cache=60000","BOName":"Test","path":"/toto/"},
{"displayName":"Bienvenue","URLPage":"preprod.test.com/page/ac73b/4774.json?cache=60000","BOName":"Test","path":"/tata/"},
{"displayName":"Bienvenue","URLPage":"preprod.test.com/page/ac73b/4745.json?cache=60000","BOName":"Test","path":"/titi/"},
{"displayName":"Bienvenue","URLPage":"preprod.test.com/page/ac73b/4799.json?cache=60000","BOName":"Test","path":"/tutu/"} 

在此示例中,我想根据序列 IE 中的变量捕获 URLPage 值

  • 对于 toto:preprod.test.com/page/ac73b/4579.json?cache=60000
  • 对于塔塔:preprod.test.com/page/ac73b/4774.json?cache=60000

正则表达式("""URLPage":"(.+?)".*?"path":"/${rubrique}/"""

匹配并捕获下面斜体的字符串,这是合乎逻辑的,但这不是我想要做的(以粗体显示模式)

塔塔

"URLPage":" preprod.test.com/page/ac73b/4579.json?cache=60000 ","BOName":"Test","path":"/toto/"}, {"displayName":"Bienvenue ","URLPage":" preprod.test.com/page/ac73b/4774.json?cache=60000 ","BOName":"Test","path":"/tata/

对于芭蕾舞短裙

"URLPage":" preprod.test.com/page/ac73b/4579.json?cache=60000 ","BOName":"Test","path":"/toto/"}, {"displayName":"Bienvenue ","URLPage":"preprod.test.com/page/ac73b/4774.json?cache=60000","BOName":"Test","path":"/tata/"}, {"displayName": "Bienvenue","URLPage":"preprod/test.com/page/ac73b/4745.json?cache=60000","BOName":"Test","path":"/titi/"}, {"displayName ":"Bienvenue","URLPage":" preprod/test.com/page/ac73b/4799.json?cache=60000 ","BOName":"Test","path":"/tutu/"}

我怎样才能正确地做到这一点?

谢谢

杰罗姆

4

0 回答 0