You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm enjoying your book on python 3, but I don't understand the part in chapter 5 where you talk about raw strings. It seems that by adding r in front of '\bROAD$' you should achieve the opposite of what you want to, which is to have \b interpreted as a word boundary. Instead you'd get a slash followed by a b. In other words, why would you want the \ to be escaped here?
Except of course that the code works. But I don't know why it does. I'm suspecting it's because you want to ignore normal escape characters but not certain ones that the re module uses. Is that right?
The text was updated successfully, but these errors were encountered:
You want a backslash in the string that you pass to the re.sub method, which interprets the "\b" as a boundary specifier. In a normal string, "\b" is a backspace character.
Hi Mark,
I'm enjoying your book on python 3, but I don't understand the part in chapter 5 where you talk about raw strings. It seems that by adding r in front of '\bROAD$' you should achieve the opposite of what you want to, which is to have \b interpreted as a word boundary. Instead you'd get a slash followed by a b. In other words, why would you want the \ to be escaped here?
Except of course that the code works. But I don't know why it does. I'm suspecting it's because you want to ignore normal escape characters but not certain ones that the re module uses. Is that right?
The text was updated successfully, but these errors were encountered: