Loadrunner,无效的正则表达式,为什么?

Loadrunner, invalid regular expression, why?

我很困惑。 为什么 loadrunner 会抛出正则表达式错误?

web_reg_save_param_regexp(
    "ParamName=token",
    "RegExp=token=(.*?);",
    "Ordinal=All",
SEARCH_FILTERS,
    "Scope=Cookies",
LAST );

在此处捕获文本:

Set-Cookie: token=5c251325c6ba7a7294c1da9b%2FgxnEVacZjfiAHUY2eulpgpko4yMp93lG1ACKYKZcrK2tnDAIspXOsCQkzyPYH34S; Path=/; Expires=Mon, 16 Nov 2020 10:08:38 GMT; Secure
Set-Cookie: hasAccount=password; Path=/; Expires=Tue, 17 Dec 2019 10:08:38 GMT

输出错误:

Action.c(24): pcre_compile error: "this version of PCRE is compiled without UTF support" detected at pattern location:0     [MsgId: MMSG-26000]

I googled this problem, one hint was invalid regular expression. Try following solution.

首先尝试像往常一样评论 coockies 和 运行 脚本。请避免使用 (.*?)。我大部分时间都在使用它时遇到失败,I would suggest you to read this article on regular expression

web_reg_save_param_regexp(
    "ParamName=token",
    "RegExp=token=[a-zA-Z0-9%]+;",
    "Ordinal=All",
SEARCH_FILTERS,
    "Scope=Cookies",
LAST );

尝试用“+”代替“*”。另外,这取决于LR版本。下面是更新后的代码

web_reg_save_param_regexp(
    "ParamName=token",
    "RegExp=token=(.+?);",
    "Ordinal=All",
SEARCH_FILTERS,
    "Scope=Cookies",
LAST );