Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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!

share|improve this question
    
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
add comment

2 Answers

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+)
share|improve this answer
    
Thanks man.. this worked. –  acamso Apr 12 '13 at 20:52
    
Nice, so you should accept answer :) –  maxxvw Apr 13 '13 at 20:14
add comment

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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