Regular expression gone mad

fileexit mayyash at gmail.com
Mon Feb 20 05:55:42 EST 2006


Hi,
Would someone please tell me what is going on here??!! Why does the
following code work

>>> a=r"Mem"
>>> pat = re.compile(a)
>>> m=pat.search(ProcMem, re.DOTALL)
>>> m
<_sre.SRE_Match object at 0xb7f7eaa0>
>>> m.group(0)
'Mem'


But this one does not!!! (Search finds nothing)

>>> a=r"MemT"
>>> pat = re.compile(a)
>>> m=pat.search(ProcMem, re.DOTALL)
>>> m


ProcMem contains:

>>> print ProcMem
MemTotal:      8247952 kB
MemFree:       5980920 kB
Buffers:        417044 kB
Cached:         703036 kB
SwapCached:          0 kB
Active:        1440136 kB
Inactive:       370668 kB
HighTotal:     7405512 kB
HighFree:      5977600 kB
LowTotal:       842440 kB
LowFree:          3320 kB
SwapTotal:     8339440 kB
SwapFree:      8339296 kB
Dirty:              96 kB
Writeback:           0 kB
Mapped:         786672 kB
Slab:           359208 kB
Committed_AS:  2453912 kB
PageTables:      24696 kB
VmallocTotal:   106488 kB
VmallocUsed:      8700 kB
VmallocChunk:    96708 kB
HugePages_Total:     0
HugePages_Free:      0
Hugepagesize:     2048 kB




More information about the Python-list mailing list