Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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.
/filter=(\d+)/
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)
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
/filter=(\d+)/