Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Adding Double quotes inside Reg-EX xpath evaluation

Parasofttoudaya
Parasofttoudaya Posts: 232 ✭✭
edited September 2017 in SOAtest

Hi Team,

I am trying to concat a json string with my json databank result
It supossed to be result as {"hashvalue":"hascontentFromXPath"}.

As i am not able to pass "(double quote) inside the reg-ex, i just passed single quote get the below result.
concat("{'hashvalue':" ,"'","hascontentFromXPath","'","}") ===> {'hashvalue':'hascontentFromXPath'}

is there any way to insert double quotes in it. ??

Note:
Below thready says i have to use backslash before double quote, its not working parasoft.
https://stackoverflow.com/questions/16761596/how-to-represent-the-double-quotes-character-in-regex

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    In XPath, use two double quotes to escape a single double quote:
    concat("{""hashvalue"":""", /some/xpath/text(), """}")

  • OmarR
    OmarR Posts: 233 admin
    edited September 2017

    IT may be easier to wrap each section in a single quote, like so:

    concat ( ' {"hashvalue": ' , ' " ', /root/pennywise[1]/text() , ' " ', ' } ')

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    Thanks OMAR, its working.

    I did tried ' " ', but inside two double quotes :(