Tools, FAQ, Tutorials:
re.split() - Splits with Regular Expression
How to split a given string with a regular expression as the delimiter using re.split()?
✍: FYIcenter.com
The re.split() function allows you to split a given target string using matches of a given regular expression as the delimiter.
import re l = re.split(pattern, string, maxsplit=0, flags=0) Where: pattern is the regular expression string is the target string maxsplit=0 means spliting all matches l is the list of sub-strings resulted from the spliting
Here is Python example that shows you how to use the re.findall() function:
>>> import re >>> s = "Hello perl.org, php.net, and python.org!" >>> p = "\\W+" >>> print(p) \W+ >>> l = re.split(p,s) >>> print(l) ['Hello', 'perl', 'org', 'php', 'net', 'and', 'python', 'org', '']
⇒ 'json' Module - JSON Encoder and Decoder
⇐ Use Match Group \g<n> in Replacement
2018-10-13, 1787🔥, 0💬
Popular Posts:
How to Build my "sleep" Docker image from the Alpine image? I want the container to sleep for 10 hou...
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a...
How to view API details on the Publisher Dashboard of an Azure API Management Service? You can follo...
How To Access a Global Variable inside a Function? in PHP? By default, global variables are not acce...
How To Pass Arrays By References? in PHP? Like normal variables, you can pass an array by reference ...