Re: Bug in re.findall?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richie Hindle

    Re: Bug in re.findall?

    Hi Marcin,
    subnetlist="192 .168.100.0 , 192.168.101.0"
    ipre=re.compile ("([0-9]{1,3}\.){3}[0-9]{1,3}")
    >
    >ipre.findall(s ubnetlist)
    ['100.', '101.']
    Correct - it returns the most recently captured text for your sole group.
    a=ipre.finditer (subnetlist)
    >a.next().group ()
    '192.168.100.0'
    Also correct, because match.group() returns the whole of the matched text.
    If you wanted just your captured piece, you need this:
    >a.next().group (1)
    '100.'
    Hope that helps!

    --
    Richie Hindle
    richie@entrian. com

Working...