简体   繁体   English

原始字符串包含“ +”,正则表达式提取器(。+?)将其替换为空格。 我如何用“ +”提取

[英]Original string contains “+”, regular expression extractor (.+?) replaces it with a space. How can I extract with the “+”

(Edit: The answer is to use check 'Encode?'option in the HTTP Request. Please see Vinoth's Edit 2 and comment below, thanks!) (编辑:答案是在HTTP请求中使用check'Encode?'选项。请参见Vinoth的Edit 2并在下面发表评论,谢谢!)

This is interesting! 这是有趣的!

I'm trying to parse a HTTP response which has (let's give concrete example, 我正在尝试解析具有以下内容的HTTP响应(下面给出具体示例,

bigH:"2a3a6CEH+iJakQpQtPm8efv"

Using Regular Expression Extractor when I try 我尝试使用正则表达式提取器

bigH:"(.+?)"

it extracts the string but replaces all the "+" in the string with space. 它提取字符串,但用空格替换字符串中的所有“ +”。 That is, instead of 也就是说,代替

"2a3a6CEH+iJakQpQtPm8efv" 

it gives me: 它给了我:

"2a3a6CEH iJakQpQtPm8efv"

Note the space between H and i. 注意H和i之间的空间。

How can I stop it from replacing the "+" with a space? 如何停止用空格代替“ +”? I'd really appreciate if someone can give an explanation also. 如果有人也能提供解释,我将不胜感激。

Btw, I tried (.+?) and (.\\++?) and even ([.|\\+]+?) - didn't work :( 顺便说一句,我尝试了(.+?)(.\\++?)甚至([.|\\+]+?) -都没用:(

Thanks, --Ishtiaque 谢谢,--Ishtiaque

Updating with screenshots below: 使用以下屏幕截图进行更新:

Adding screenshots: POST Response data: 添加屏幕截图:POST响应数据: 在此处输入图片说明

After parsing with regular expression extractor in JMeter: 在JMeter中使用正则表达式提取器进行解析后: 在此处输入图片说明

Side by side in Notepad++: 在Notepad ++中并排: 在此处输入图片说明

'Raw' tab shows the '+'s: “原始”标签显示“ +”: 在此处输入图片说明

'HTTP' tab does not: “ HTTP”标签没有: 在此处输入图片说明

尝试使用正则表达式([a-zA-Z0-9+]+)

As you get the response in JSON format, I would go with JSON Path Extractor . 当您获得JSON格式的响应时,我将使用JSON Path Extractor

It seems to be a much easier approach than using Regular expression. 这似乎比使用正则表达式容易得多。

Below JSON Path should take care of getting the encoded string from your JSON & You should be able to access using ${bigH} . JSON Path下面应注意从JSON获取编码的字符串,并且您应该可以使用${bigH}进行访问。

在此处输入图片说明

Check this for more details (scroll down for JSON Path extractor details). 检查以获得更多详细信息(向下滚动以获取JSON Path提取器详细信息)。


EDIT: 编辑:

I was wrong that You get the response in JSON format. 我错了,您得到的响应格式为JSON。 Are you trying to access - bigH:"XXX" - from script tag? 您是否要从脚本标签访问-bigH:“ XXX”? For this, We have to use Regular expression extractor only or Beanshell. 为此,我们必须仅使用正则表达式提取器或Beanshell。

<script type='text/javascript' charset='utf-8'>

    registerSubmit(document.forms[0].elements['SubmitTopButton']);
    registerSubmit(document.forms[0].elements['SubmitBottomButton']);

    (function($) {
        $(".wb_tsauthall").wb_tsauthall({
            auth    : "Authorize All", 
            unauth  : "Unauthorize All",
            locMsgKeys : []
        });

        $(".wb_newedit").wb_newedit({
            labels:['Job','Code','Work Premium','Flat Rate','Premium','Shift','Sched Times','LTA','Sched Times w Breaks','Delete Details','Employee Holiday','Work Detail','Schedule Detail'],values:[105,103,200,206,204,450,401,500,461,199,900,100,460],bigH:"PVxUbYIODBT31j8IZnPGxF/9O1iuKAkFzTO9WhXu8An8hAUa22tLiWrEHz8v9SIu/NXZH1a5IxO0xYeNwRIYM+3n1kNsrESnhiAYhwhCiqUY9mI4hvEPgAOx7B+MEB8iSIUyNGNZbeGx9nSogFYpNrzmCXirW7Nm9Tn7owPKHmc8dOf5SZ+eDzAOHIB8+5YzQ3bIdFoe60hOMkyd7FiUXtwPcNMUFEjOSMs9JhgIHTE4agpCdbFb6SLuSuLoO9rqxj+9GovUbzTmrxj4faBKZVATNN7iIFyDZHYAZuZRcPJBdUJ1xNHMCWyPZ4p2/Yk0Q0ujdKJbJw9NFysikZgBFNEhNXEA4w8HL1ycYCmZDgSUW1GsumDAKh0Brq3K8Kh2akep8YEjDMWipKgSPaNx3CVY4lf87e0oK70nK/zKGkmpWFvyMnxbkJtWmeuxmPgRZgg2lYbZXFauD1AidnQQhPULJTTV+P+Xkk9PYm3ZkIEcDnYJUmPg/D3iuwg84m2IZatFTdjiNuDAcGNKptTd54yMgohN87c3sRMiZlSY/r88u+Le3BKWJqyl7Xai7Odqz366DFgOzdPi92LnSaggKX++hy+Z04kjyfSZOUYWmiWlc38SUdeTq2v15egig2mMkSLMaUnHagk="
        });


        $("#codeSummaryBar").wb_expandableframe({ 
            iframe : contextPath + '/dailytimesheet/summaryInline.jsp'
        });

        $("#codeSummaryBar").click(function(){$("#codeSummaryBar_expand_collapse_icon").toggleClass("collapse expand");});
        $("#codeSummaryBar").click();


        $("#selectionBar").wb_expandableframe({ 
            iframe : contextPath + '/dailytimesheet/dailySelectInline.jsp',
            onExpand : function() {
    $(".selectionBarControl").css("visibility", "hidden");
    $("#expand_collapse_icon").removeClass("expand").addClass("collapse");
            },
            onCollapse : function() {
    $(".selectionBarControl").css("visibility", "");
    $("#expand_collapse_icon").removeClass("collapse").addClass("expand");
            }
        });



        DTS.onload();



    })(jQuery);

</script>

EDIT 2: 编辑2:

I doubt that you might have checked the Encode in the HTTP Request. 我怀疑您可能已经检查了HTTP请求中的Encode
Uncheck 取消选中

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用正则表达式检查字符串是否包含逗号和空格? - How I can do to check if a string contains a comma with a space using a regular expression? jmeter正则表达式提取器从多字符串中提取字符串 - jmeter Regular Expression Extractor to extract string from multi string 如何使用Php正则表达式提取字符串 - How can I extract string using Php regular expression 如何使用正则表达式提取器从JMeter中的字符串中提取固定数量的字符? - How to extract fixed number of characters from string in JMeter using regular expression extractor? 如何使用正则表达式提取器从响应头中提取元素 - How to extract the element from the response header using Regular Expression Extractor 如何从jmeter响应中提取正则表达式提取器? - how to extract Regular expression extractor from jmeter response? 如何在JMeter中使用正则表达式提取器提取某些值? - How to extract certain values using regular expression extractor in JMeter? 如何使用正则表达式提取器在jmeter中提取json响应数据? - how to extract json response data in jmeter using regular expression extractor? 如何使用正则表达式提取器从jmeter中的响应中提取值 - how to use Regular expression extractor to extract value from response in jmeter 如何使用正则表达式提取器提取jmeter中的Json值? - How to extract the Json values in jmeter using regular expression extractor?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM