benhowdle89
benhowdle89

Reputation: 37464

jQuery regex/delete certain words from URL

Given the URL: http://domain.com/view/2/permalink:14871638741230

What is the best method, using jQuery/Javascript to delete the "permalink:xxxxx" from the URL, obviously bearing in mind that the number with the permalink will change from URL to URL...

Thanks

Upvotes: 0

Views: 930

Answers (1)

pimvdb
pimvdb

Reputation: 154828

What about a regexp?

url = url.replace(/permalink:[a-zA-Z0-9]+/g, "");

It will replace permalink:<one or more lowercase/uppercase letters and numbers> with an empty string, i.e. removing it.

Upvotes: 3

Related Questions