Help for this page

Select Code to Download


  1. or download this
    import re
    r = re.compile(r'(?P<A> a (?P<B> b))', re.X)
    ...
                                     # 'B => b'
    print m.group('A')               # 'ab'
    print m.group('B')               # 'b'
    
  2. or download this
    'ab' =~ /(?<A> a (?<B> b))/x;
    print "$_ => $+{$_}\n" for (keys(%+));    # 'A => ab'
                                              # ... nothing, thats it
    print "$+{'A'}\n";                        # 'ab'
    print "$+{'B'}\n";                        # 'b'