Is there a metacharacter to match transitions between any two of aset of non intersected char classe

P

Peng Yu

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
 
M

MRAB

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top