Is there a metacharacter to match transitions between any two of a set of non intersected char classes?

Peng Yu PengYu.UT at gmail.com
Thu Jul 24 19:48:05 CEST 2008


Hi,

'\b' only match the boundary between alphanumerical char and
nonalphanumerical char. I'm wonder if there is a generic metacharacter
to match the boundary between any non intersected char set defined in
regex and its complement.

For example, I have a few non intersected char sets [a-zA-Z_0-9], [:]
and [\s], and lets call the new metacharactor \m.

r"abc\m" would be the same as r"abc\b"
r"abc:\m' would match "abc:" in r"abc:xy" but not "abc::xy"
r"a \m" (with one space) would match "a " (with one space) in "a abc"
but not "a  abc" (with two spaces).

I would like that I have the flexibility to define more non
intersected char sets, while I don't want change the regex that I have
written.

Thanks,
Peng



More information about the Python-list mailing list