Gatling,Scala,正则表达式和最短的匹配

时间:2016-08-01 09:15:00

标签: regex scala gatling shortest

我遇到了一个无法解决的问题。我愿意根据变量捕获带有正则表达式的模式,我希望得到最短的匹配(不是第一次匹配,但是最后一次也是最短的匹配)

这是gatling伪代码

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/"} 

在这个例子中,我想根据序列中的变量捕获URLPage值 即

  • for toto:preprod.test.com/page/ac73b/4579.json?cache=60000
  • for tata:preprod.test.com/page/ac73b/4774.json?cache=60000
  

正则表达式( “” “URLPage”: “?(+)” * “路径”:? “/ $ {rubrique} /” “”

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

对于tata

  

“URLPage”: “ preprod.test.com/page/ac73b/4579.json?cache=60000 ”, “BOName”: “测试”, “路径”:“/ TOTO / “},           { “显示名”: “Bienvenue”, “URLPage”: “的 preprod.test.com/page/ac73b/4774.json?cache=60000 ”, “BOName”: “测试”,“路径“:”/塔塔/

对于tutu

  

“URLPage”: “ preprod.test.com/page/ac73b/4579.json?cache=60000 ”, “BOName”: “测试”, “路径”:“/ TOTO / “},       { “显示名”: “Bienvenue”, “URLPage”: “preprod.test.com/page/ac73b/4774.json?cache=60000","BOName":"Test","path":"/tata/” },       { “显示名”: “Bienvenue”, “URLPage”: “preprod / test.com /页/ ac73b / 4745.json缓存= 60000?”, “BOName”: “测试”, “路径”: “/蒂蒂/” },       { “显示名”: “Bienvenue”, “URLPage”: “的 preprod / test.com /页/ ac73b / 4799.json缓存= 60000 ?”, “BOName”: “测试”,“路径“:”/ tutu /“}

我该如何正确地做到这一点?

由于

杰罗姆

0 个答案:

没有答案