I am trying to figure out how to replace example:
sw1_code1_number1_jpg      --> code1_number1_jpg
hon2_noncode_number2_jpg   --> noncode_number2_jpg
ccc3_etccode_number3_jpg   --> etccode_number3_jpg
ddd4_varcode_number4_jpg   --> varcode_number4_jpg
So the results are all string after the first _ If it doesn't find any _ then do nothing.
I know how to find and replace strings, str.replace, indexof, lastindexof but dont know how remove up to the first found occurrence.
Thank You
Use the replace method with a regular expression:
"sw1_code1_number1_jpg".replace(/^.*?_/, "");
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With