Home >Backend Development >Python Tutorial >Python split string with multiple delimiters

Python split string with multiple delimiters

藏色散人
藏色散人Original
2019-03-04 14:46:0812499browse

A python delimiter is a sequence of one or more characters used to specify boundaries between separate independent regions in plain text or other data streams; an example of a delimiter is the comma character, which acts as a comma-separated value Field separator in the sequence.

Python split string with multiple delimiters

A delimiter is a sequence of one or more characters used to specify boundaries between separate, independent regions in plain text or other data streams. An example of a delimiter is the comma character, which acts as a field separator in a sequence of comma-separated values.

Python split string with multiple delimiters

Python code:

import re
text = 'The quick brown\nfox jumps*over the lazy dog.'
print(re.split('; |, |\*|\n',text))

Output:

['The quick brown', 'fox jumps', 'over the lazy dog.']

Flow chart:

Python split string with multiple delimiters

Recommended related Python video tutorials: "Python Tutorial"

This article is an introduction to python delimiters. I hope it will be helpful to friends in need!

The above is the detailed content of Python split string with multiple delimiters. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn