I have checked a number of posts and regex examples but for some reason I can't get the leading 0's to be removed from the date string below. Can anyone see what I am doing wrong?
What I have tried:
String shipDate = '04/06/2022'; String shipDate2 = '04/06/2022'; String shipDate3 = '04/06/2022'; String shipDate4 = '04/06/2022'; system.debug('1::: ' + shipDate.replaceFirst('^0+', '')); system.debug('2::: ' + shipDate2.replaceFirst('^0+(?!$)', '')); system.debug('3::: ' + shipDate3.replaceAll('/\b0/g', '')); system.debug('4::: ' + shipDate4.replaceFirst('\b0/g', ''));
I have tried all of these suggestions: https://stackoverflow.com/questions/8897298/remove-leading-zeroes-in-datestring and can see here https://regex101.com/ that the \b0 works...is there something with apex that doesn't like regex expressions formatted like this?