Can anyone tell me how I would remove characters from a string if they are present?

For example lets say I wanted to remove c:/fakepath/ from the string c:/fakepath/DSF102.jpg and just leave the DSF102.jpg how would I got about this?

I got close but I need help.

Thanks in advance


To Accomplish this , you should use the string method replace()
which takes 2 arguments the portion you want to replace and what you want to replace it with

so , in your case you need to replace the whole string except the image name with nothing in the main string
so the code will be like this

var string = "c:/fakepath/DSF102.jpg";
var newString = string.replace ("c:/fakepath/","");
// now the variable newString holds the value DSF102.jpg 
// To Test it

Hope this helps =)