Re: how to match whole word

2008-07-16 Thread Fredrik Lundh
John S wrote: > Not sure why you picked \A and \Z -- they are only useful if you are > using the re.M flag. Well, they're aliases for ^ and $ in "normal" mode, at least for strings that don't end with a newline. re.I is the same as re.IGNORECASE. More than one option may be OR'ed together. T

Re: how to match whole word

2008-07-16 Thread John S
On Jul 16, 9:38 am, Peng Yu <[EMAIL PROTECTED]> wrote: > On Jul 15, 10:29 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > > > > > Peng Yu wrote: > > > Hi, > > > > The following code snippet is from /usr/bin/rpl. I would like the it > > > to match a word, for example, "abc" in ":abc:". But the current

Re: how to match whole word

2008-07-16 Thread Fredrik Lundh
Peng Yu wrote: I didn't read the docs and tried the following code. regex = re.compile(r"\A" + re.escape(old_str) + r"\Z", opts.ignore_case and re.I or 0) But I'm not sure why it is not working. as the documentation says, \A and \Z matches at the beginning/end of a *string*, not a word.

Re: how to match whole word

2008-07-16 Thread Peng Yu
On Jul 15, 10:29 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > Peng Yu wrote: > > Hi, > > > The following code snippet is from /usr/bin/rpl. I would like the it > > to match a word, for example, "abc" in ":abc:". But the current one > > would not match "abc" in ":abc:". I tried to modify it myself.

Re: how to match whole word

2008-07-15 Thread Gary Herron
Peng Yu wrote: Hi, The following code snippet is from /usr/bin/rpl. I would like the it to match a word, for example, "abc" in ":abc:". But the current one would not match "abc" in ":abc:". I tried to modify it myself. Would you please let me know what is the corrected way to do it? Thanks, Pen

how to match whole word

2008-07-15 Thread Peng Yu
Hi, The following code snippet is from /usr/bin/rpl. I would like the it to match a word, for example, "abc" in ":abc:". But the current one would not match "abc" in ":abc:". I tried to modify it myself. Would you please let me know what is the corrected way to do it? Thanks, Peng if opt