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
mahesh9999mahesh9999 

How split a special character string using APEX and i want to store it into a salesforce account object


MSH|^~\&|REGADT0|MCM|RSP18P|""|${sysdt}|SECURITY|ADT^A28|MSG00002|P|2.3||
EVN|A28|${sysdt}||02||
PID||||${AccountId}|${Lastname}^${Firstname}^||${DOB}|${Gender}||${Race}|${MailingStreet}^${MailingStreet2}^${MailingCity}^${MailingState}^${MailingZip}||${Phone}|${Phone}||${MaritalStatus}|||${SSN}|
PD1||||5||||||||
IN1|1|${InsuranceId}|${InsuranceId}|${InsuranceProvider}|${InsuranceAddress}^^${InsuranceCity}^${InsuranceState}^${InsuranceZip}||||||||||||||||||||||||||||||||||||||||||||
IN2|1||||||||||||||||||||||||||||
NTE|1||
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

You can use below line of code to replace all special characters.
 
myString.replaceAll('[^a-zA-Z0-9]', '');

Please refer to the below links which might help you further with the above requirement.

http://theblogreaders.com/how-to-split-the-special-characters-using-apex-class/

http://theblogreaders.com/splitting-string-example-in-salesforce-apex-class/

https://developer.salesforce.com/forums/?id=906F00000008z76IAA

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas