Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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
Required, but never shown
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.
Explore related questions
See similar questions with these tags.
/filter=(\d+)/