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!

1
  • 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. Commented Apr 12, 2013 at 21:33

2 Answers 2

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
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.

1
  • The (?: ... ) clustering notation does not match literal characters, but simply allows for subexpressions without capturing back-references. Commented Apr 12, 2013 at 21:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .