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

MRAB google at mrabarnett.plus.com
Thu Jul 24 21:40:41 EDT 2008


On Jul 24, 6:48 pm, Peng Yu <PengYu... at gmail.com> wrote:
> 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.
>
Interesting idea. It could be added, but how much demand is there for
it?



More information about the Python-list mailing list