nikitautiu
nikitautiu

Reputation: 982

Python regular expressions

Is there any regular expression to match this:

?

Examples:

Upvotes: 0

Views: 280

Answers (2)

tzot
tzot

Reputation: 95911

Perhaps relevant: do you know about the shlex module?

Upvotes: 1

Antoine Pelisse
Antoine Pelisse

Reputation: 13099

Maybe you can try this:

>>> message = "blabla df qdsf dqsf \"fqdfdqsfsdf  fdqs fqdsf\""
>>> pattern = "(\w+|'.*[^']'|\".*[^\"]\")"
>>> re.findall(pattern, message)
['blabla', 'df', 'qdsf', 'dqsf', '"fqdfdqsfsdf  fdqs fqdsf"']

Upvotes: 0

Related Questions