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. </F>