the solution is to use raw strings these are quoted or triple quoted strings whose first quote is preceded by the letter inside such strings all characters are taken to be literalsso no escaping is necessary here is the phone regular expression using raw stringphone re compile( "^((?:[(]\ +[)])?\ *\ +(?:-\ +)?)$"if we want to write long string literal spread over two or more lines but without using triple quoted string there are couple of approaches we can taket "this is not the best way to join two long strings "together since it relies on ugly newline escapings ("this is the nice way to join two long strings "togetherit relies on string literal concatenation "notice that in the second case we must use parentheses to create single expression--without thems would be assigned only to the first stringand the second string would cause an indentationerror exception to be raised the python documentation' "idioms and anti-idiomshowto document recommends always using parentheses to spread statements of any kind over multiple lines rather than escaping newlinesa recommendation we endeavor to follow since py files default to using the utf- unicode encodingwe can write any unicode characters in our string literals without formality we can also put any unicode characters inside strings using hexadecimal escape sequences or using unicode names for exampleeuros \ {euro sign\ ac \ acprint(eurosin this case we could not use hexadecimal escape because they are limited to two digitsso they cannot exceed xff note that unicode character names are not case-sensitiveand spaces inside them are optional if we want to know the unicode code point (the integer assigned to the character in the unicode encodingfor particular character in stringwe can use the built-in ord(function for exampleord(euros[ ] hex(ord(euros[ ])' acsimilarlywe can convert any integer that represents valid code point into the corresponding unicode character using the built-in chr(functioncharacter encodings