Split takes a regular expression as its first parameter, not a string. The period character means any character in regex land, so you need to escape it with a backslash.
Split takes a regular expression as its first parameter, not a string. The period character means any character in regex land, so you need to escape it with a backslash.
Hi , i have string like below 3/7/2020 8:48 PM - please - check the document one two three 3/7/2020 9:11 PM - looks good now 3/7/2020 9:12 PM - test , i need to split it between time stamp and the text,how can i do it?
Split takes a regular expression as its first parameter, not a string. The period character means any character in regex land, so you need to escape it with a backslash.
Try:
All Answers
Split takes a regular expression as its first parameter, not a string. The period character means any character in regex land, so you need to escape it with a backslash.
Try:
Try out the sample code given below :
String strTest = 'test.test1';
String arrTest = strTest.split('\\.')[1];
Hope this will work.
Thanks Bob & Pradeep! It make sense.
String[] arrTest = strTest[0].split('\.');
3/7/2020 9:11 PM -
looks good now
3/7/2020 9:12 PM -
test , i need to split it between time stamp and the text,how can i do it?
This is perfect answer
String strTest = 'test.test';
String[] arrTest = strTest.split('\\.');
Please marked as correct answer