0

I need to match only urls C and D.

Given I have these sites:

a.  http://www.website.com/our-resources/news/?p=1
b.  http://www.website.com/example/voice-of-the-customer/news/?p=12
c.  http://www.website.com/our-resources/news/?p=123
d.  http://www.website.com/example/?p=4321
e.  http://www.website.com/example/products/touchchat/news/?p=12345

I was using .*\?((.*=.*)(&?[0-9]{3,4})) on www.regexpal.com and it's matching c, d and e.

1
  • What is the criterion based on which you want to select? Commented Apr 19, 2016 at 6:27

2 Answers 2

1

You can use this regex:

/[^?]*\?.*=\d{3,4}(?:&|$)/

This will only match a URL with query parameter with 3 or 4 digits only (c & d test cases in your question).

RegEx Demo

Sign up to request clarification or add additional context in comments.

Comments

0

Use this:

.*\?((.*=)([0-9]{3,4}))

It was caused by the second .* in .*=.*

Comments

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.