#python 의 #정규 표현 의 그 r 로 패턴을 둘러싸고 있는 녀석‥저녀석‥뭐야‥장난하지마‥답은? (raw string 표기법)
파이썬에서 정규식을 사용하는 방법 - Qiita
그런 다음 패턴의 시작 부분에 r을 붙이는 것이 좋습니다. 이해하기 쉽습니다.
re — Regular expression operations — Python 3.7.3 documentation
Regular expressions use the backslash character ('\') to indicate special forms or to allow special characters to be used without invoking their special meaning. This collides with Python's usage of the same character for the same purpose in string literals; match a literal backslash, one might have to write '\\' as the pattern string, because the regular expression must be\, and each backslash must be expressed as\inside a regular Python string literal.
The solution is to use Python's raw string notation for regular expression patterns; backslashes are not handled in any special way in a string literal prefixed with 'r'. So r"\n"is a two-character string containing '\' and ' n', while "\n"is a one-character string containing a newline. Usually patterns will be expressed in Python code using this raw string notation.
e.g
>>> re.search('\\\\', "A\\B\\C")[0]
'\\'
>>> re.search(r'\\', "A\\B\\C")[0]
'\\'
원시 문자열이란?
Original by Github issue
Reference
이 문제에 관하여(#python 의 #정규 표현 의 그 r 로 패턴을 둘러싸고 있는 녀석‥저녀석‥뭐야‥장난하지마‥답은? (raw string 표기법)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/YumaInaura/items/6a9d73aff2db1a0dfc03
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
>>> re.search('\\\\', "A\\B\\C")[0]
'\\'
>>> re.search(r'\\', "A\\B\\C")[0]
'\\'
Original by Github issue
Reference
이 문제에 관하여(#python 의 #정규 표현 의 그 r 로 패턴을 둘러싸고 있는 녀석‥저녀석‥뭐야‥장난하지마‥답은? (raw string 표기법)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/YumaInaura/items/6a9d73aff2db1a0dfc03
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(#python 의 #정규 표현 의 그 r 로 패턴을 둘러싸고 있는 녀석‥저녀석‥뭐야‥장난하지마‥답은? (raw string 표기법)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/YumaInaura/items/6a9d73aff2db1a0dfc03텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)