0
votes

(Edit: The answer is to use check 'Encode?'option in the HTTP Request. Please see Vinoth's Edit 2 and comment below, thanks!)

This is interesting!

I'm trying to parse a HTTP response which has (let's give concrete example,

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.

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

Updating with screenshots below:

Adding screenshots: POST Response data: enter image description here

After parsing with regular expression extractor in JMeter: enter image description here

Side by side in Notepad++: enter image description here

'Raw' tab shows the '+'s: enter image description here

'HTTP' tab does not: enter image description here

2
Regular expressions don't replace anything, they just match. Is that string coming from a URL parameter? In URLs, + is automatically converted to space.Barmar
It shouldn't behave like that, maybe it has to do with how the string get's outputted? What language are you using? What development environment?gitaarik
I just tried it in JMeter itself. It does not replace the +. I get the 2a3a6CEH+iJakQpQtPm8efv as expectedvins
Ok, here is the thing. @VinothS and others, you are right. It is getting the '+' in the regular expression and not replacing with space. The problem is, the 'HTTP' tab for the 'Request' in 'View Result Tree' listener, is not showing them. When I switch to the 'Raw' tab, I now see the '+'s. May be it just omits them trying to pretty print and is an issue? Please see the attached screenshot:Ishtiaque Hussain
@IshtiaqueHussain, Check the EDIT 2vins

2 Answers

1
votes

As you get the response in JSON format, I would go with 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}.

enter image description here

Check this for more details (scroll down for JSON Path extractor details).


EDIT:

I was wrong that You get the response in JSON format. Are you trying to access - bigH:"XXX" - from script tag? For this, We have to use Regular expression extractor only or 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:

I doubt that you might have checked the Encode in the HTTP Request.
Uncheck

enter image description here

1
votes

Try with the regular expression ([a-zA-Z0-9+]+)