0

What I am trying to do is to create a small Chrome extension that will automatically trim the &bar= parameter from a list of links

So a link such as:

http://www.website.com/page&foo=2&bar=3

Becomes:

http://www.website.com/page&foo=2

Alternatively a solution where just copying the links will remove the &bar= parameters will do.

2
  • The query portion of a URL starts with ?, not & Commented Sep 18, 2012 at 14:17
  • have a look into regular expressions w3schools.com/jsref/jsref_obj_regexp.asp Commented Sep 18, 2012 at 14:19

1 Answer 1

1

Use replace, for example:

var s = 'http://www.website.com/page&foo=2&bar=3';
s.replace(/&bar=[^&]*/, "");
Sign up to request clarification or add additional context in comments.

2 Comments

Maybe * is better: /&bar=[^&]*/.
@VisioN: Indeed, thanks, it's possible that bar's value is empty.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.