Skip to main content

Posts

Showing posts with the label saleforce

How to split String from the character '*' ?

 This is a bug in split function, it does not work for '*'  or '+'.  We will get runtime error. System.StringException: Invalid regex: Dangling meta character '*' near index 0 *  String sBody = '*   Building Name:Brookwood Gardens  *   Is your unit isolated with barrier systems in place?Yes  *   Does your unit have its own supplies?Yes  *   Does your unit have any additional infection control equipment?HVAC filters: YesUVC lights: Yes'; List<String> strList = sBody.split('*'); // This will throw error. system.debug('strList '+strList); Solutions:  List<String> strList =sBody.split('\\*');  // This will solve.