0

I am trying to write a regex which will do the following

If I have url like

example.com?mask=33&filter=23423&mode=12

It will match substring filter=23423

I need also to consider that the url can be

example.com?filter=23423

Thanks in advance.

3
  • Might do: /filter=(\d+)/ Commented Feb 6, 2014 at 8:27
  • Once matched, what do you want to do with it? Commented Feb 6, 2014 at 8:28
  • Thanks. I want to be able to change it... Commented Feb 6, 2014 at 8:32

1 Answer 1

1

You may just not consider [\?&] in your regexp and put /filter=[0-9]*/ if you sure that there will not be any params like other_filter=987 in your url. If you may have such use substr on the resulted regexp like so

url.match(/[\?&]filter=[0-9]*/)[0].substr(1)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.