- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Let’s say the following is our URL −
We only need to get the last value and delete the rest i.e. the output should be −
For this, you can use replace() along with regular expression.
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 −
Here, my file name is demo258.js.
This will produce the following output on console −
- How to remove all text from a string before a particular character in R?
- How to delete a character from a string using python?
- Java program to delete certain text from a file
- Delete all whitespaces from a String in Java
- Delete all records from a table in MySQL?