Hi ,
I have to check in condition if a response content starts with double quote . How ever proxy is not getting saved and getting below error .
<Step>
<Name>AM-OK</Name>
<Condition>(response.content |= "\"")</Condition>
</Step>
Error -
Error in target default. Invalid condition: (message.content |= """) in policy AM-OK. Reason: Malformed expression: Unterminated "
Best Regards,
Patty
Solved! Go to Solution.
Hey Patty
Sorry for the delay. I experimented a little and I could never encode a double-quote inside the right-hand-side of a simple comparison Condition. Like |= or = or others.
But there is a regex match operator, which accepts the unicode escape for a double quote. This is what worked for me:
<Step>
<Name>AM-1</Name>
<Condition>response.content ~~ "(?s)\s*\u0022[A-Z]+\u0022\s*"</Condition>
</Step>
That ~~ is a JavaRegex matcher, in lieu of the simpler |= operator. I can explain its parts:
You can construct a different regex that is simpler or more general, if you like. Maybe something like
<Condition>response.content ~~ "(?s)\s*\u0022.+"</Condition>
...which says "any string that starts with some optional whitespace followed by a double quote."
In my tests, the (?s) is essential when matching against response.content,
even if the response.content
is a single line, or has no newlines. I don't know why.
Try
<Condition>response.content |= "\u0022"</Condition>
Hi Dino ,
response content is "OK" . But this condition is evaluating to false .
<Condition>response.content |= "\u0022"</Condition>
Best Regards,
Patty
let me try it, and get back to you.
Ok . Thank you .
Hey Patty
Sorry for the delay. I experimented a little and I could never encode a double-quote inside the right-hand-side of a simple comparison Condition. Like |= or = or others.
But there is a regex match operator, which accepts the unicode escape for a double quote. This is what worked for me:
<Step>
<Name>AM-1</Name>
<Condition>response.content ~~ "(?s)\s*\u0022[A-Z]+\u0022\s*"</Condition>
</Step>
That ~~ is a JavaRegex matcher, in lieu of the simpler |= operator. I can explain its parts:
You can construct a different regex that is simpler or more general, if you like. Maybe something like
<Condition>response.content ~~ "(?s)\s*\u0022.+"</Condition>
...which says "any string that starts with some optional whitespace followed by a double quote."
In my tests, the (?s) is essential when matching against response.content,
even if the response.content
is a single line, or has no newlines. I don't know why.
Thank you Dino . Your solution worked .
However it worked when I compared the double quotes from property set . I implemented like this .
<Condition>(message.content != null) and !(message.content =| propertyset.general.doublequote)</Condition>
Best Regards,
Patty.