Formatting string

0
Hi All , I am getting one string value in  latest http response content as – {"statusCode":500,"message":"EAI Common Internal Error: Error invoking service 'EAI Siebel Adapter', method 'Update' at step 'Update Activity'.(SBL-BPR-00162)\n--\nYou Cannot Change the Status to Pending Cancellation as the Materials charges are associated to it(SBL-EXL-00151)(SBL-EAI-00133)"}   after that i am calling a popup page to show the error msg .I only want to show – You Cannot Change the Status to Pending Cancellation as the Materials charges are associated to it. How can i format this msg from the original http response content ?  
asked
2 answers
3

What Bertalan said, but I think you want needle:

(.*--\\n)(.*?)(\(.*)

And replacement: $2

That is, if you always have literal string --\n before the part you want and a parenthesis ( after, and not inside, it.

What the regex does, is match the complete input but break it up in three parts:

- take anything up to --\n as $1

- take anything as short as possible as $2

- take anything starting with ( as $3

Now if you use RegexReplaceAll it will replace the complete input with the part stored as $2.

With the input you provided it will return:

You Cannot Change the Status to Pending Cancellation as the Materials charges are associated to it

 

answered
0

I think your best bet is to use RegexReplaceAll from Community Commons marketplace module.

The needle in the haystack is a regular expression like: .*message\":\"([^\"]+)+.*, and then the replacement is $1

Use some regular expression tester (like regex101.com) to make sure

answered