# Delete all text up to a character in a URL- JavaScript?

JavascriptWeb DevelopmentFront End TechnologyObject Oriented Programming

Let’s say the following is our URL −

https://www.tutorialspoint.com/advanced_microsoft_word_2013_tutorial/index.asp";

We only need to get the last value and delete the rest i.e. the output should be −

index.asp


For this, you can use replace() along with regular expression.

## Example

Following is the code −

var url = "https://www.tutorialspoint.com/advanced_microsoft_word_2013_tutorial/index.asp";
var getValues=url.replace(/^.*\//, '');
console.log("The original value = "+url);
console.log("New Value = "+getValues);

To run the above program, you need to use the following command −

node fileName.js.


Here, my file name is demo258.js.

## Output

This will produce the following output on console −

PS C:\Users\Amit\javascript-code> node demo258.js
New Value = index.asp