Hi,

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

Wayne

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
alert(newString);

Hope this helps =)

Great thanks

Wayne

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.