Regex does not work as expected in interpreter

python, python-2.7, regex

Solution

You need to use a raw string, or `\b` will mean "backspace" instead of "word boundary":

regexp = re.compile(r"\d+(.*?)(\bfahrenheit\b|\bf\b)", re.IGNORECASE)

Problem

I want to search through a string and find units in fahrenheit and convert them into celcius. To do this, my approach is to user regex to find units in fahrenheit in a given string, and if I find any, get the number and convert it into celcius. This is the regex I have come up with: ``` regexp = re.compile("\d+(.*?)(\bfahrenheit\b|\bf\b)", re.IGNORECASE) ``` And here is the regex in action. On the Pythex site it seems to work OK, however, in my interpreter the same regex does not match anything. Any suggestions?

Original source