Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.
This repository was archived by the owner on Jun 22, 2022. It is now read-only.

正则匹配的一个细节问题 #6

@wufeiqun

Description

@wufeiqun

self.ps1_pattern = re.compile(r'^\[?.*@.*\]?[\$#]\s|mysql>\s')

前面不应该加r, 参考:

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.

https://docs.python.org/3.6/library/re.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions