head


In [3]:
import re
p = re.compile(r'\"(.*?)\"')

In [4]:
p.findall('"rab","34","11234"')


Out[4]:
['rab', '34', '11234']

In [5]:
m= p.match('"rab","34","11234"')

In [6]:
dir(m)


Out[6]:
['__class__',
 '__copy__',
 '__deepcopy__',
 '__delattr__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 'end',
 'endpos',
 'expand',
 'group',
 'groupdict',
 'groups',
 'lastgroup',
 'lastindex',
 'pos',
 're',
 'regs',
 'span',
 'start',
 'string']

In [9]:
m.group(1)


Out[9]:
'rab'

In [10]:
dir(p)


Out[10]:
['__class__',
 '__copy__',
 '__deepcopy__',
 '__delattr__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 'findall',
 'finditer',
 'flags',
 'groupindex',
 'groups',
 'match',
 'pattern',
 'scanner',
 'search',
 'split',
 'sub',
 'subn']

In [17]:
it = p.split('"1","2","3"',',')


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-17-c00c300c617a> in <module>()
----> 1 it = p.split('"1","2","3"',',')

TypeError: an integer is required

In [12]:
it.next()


Out[12]:
<_sre.SRE_Match at 0x7f61405bac60>

In [14]:
it.next().groups()


Out[14]:
('3',)

In [16]:
it


Out[16]:
['', '1', ',', '2', ',', '3', '']

In [18]:
help (p.split)


Help on built-in function split:

split(...)
    split(string[, maxsplit = 0])  --> list.
    Split string by the occurrences of pattern.


In [ ]: