function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BPOORBPOOR 

Regex too complicated

I am working on an apex class which is making a webservice callout to an external system and with the response that I get, I am updating couple of fields on the Account object. Unfortunately, this webservice is not batched or bulkified, so I need to call this service once per account and process it one at a time. The webservice response is sometimes too big (around 1MB when saved to a file). Most of the responses are processed fine and very few of them failing with the error message "Regex too complicated".
The statement that is causing the response processing to fail is below.
 
strResponse = strResponse.replaceAll('"system"','"smsystem"');

As you can see, I am not using a pattern matcher or any kind of Regular expression. I am not sure why I am getting this error message with just a replaceAll() method.
Can someone help me in avoiding this error message?
 
VinayVinay (Salesforce Developers) 
Hi,

It depends on the content of your strResponse variable. If it is too complex, you can break the string and replace it.

Review below link which has details of above error.

https://help.salesforce.com/articleView?id=000325937&type=1&mode=1

Thanks,
Vinay Kumar