0

I am trying to match proxy patterns using the following regex:

((?:\d{1,3}\.){3}\d{1,3}):(\d+)

It is working well thus far, but is not matching the following: 218.25.249.186:80

Any ideas? Thanks!

  • Could you please provide some examples of text that is working well? Also, it would help to know which regex tool or language you are using, in case it's simply not supporting (?: ... ) or {n} notation as expected. – Bradd Szonye Apr 12 '13 at 21:33
1

This match in python regex

>>> import re
>>> ip = '218.25.249.186:80'
>>> match = re.match(r'((?:\d{1,3}\.){3}\d{1,3}):(\d+)', ip)
>>> print match
<_sre.SRE_Match object at 0xb755da88>

Could be:

(\d{1,3}\.){3}\d{1,3}:(\d+)
0

Drop the leading ':' or change it to ':?'. your reference string does not start with a : nor does a colon appear before the numeric expression.

  • The (?: ... ) clustering notation does not match literal characters, but simply allows for subexpressions without capturing back-references. – Bradd Szonye Apr 12 '13 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.