How to match word boundary?

P

Peng Yu

Hi,

I use r"\ba\b" to match "a". However, I can not use "\ba::\b" to match
"a::b".

I would like to match "a::" in "a::b", but not in "a:: b". That is,
the character after "::" should be a alphanumeric character. Could you
let me know how to do it and why "\b" would not work?

Thanks,
Peng
 
F

Fredrik Lundh

Peng said:
I would like to match "a::" in "a::b", but not in "a:: b". That is,
the character after "::" should be a alphanumeric character.

sounds like a look-ahead assertion is what you need:

</F>
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top