VOOZH about

URL: https://www.geeksforgeeks.org/python/split-and-parse-a-string-in-python/

⇱ Split and Parse a string in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Split and Parse a string in Python

Last Updated : 23 Jul, 2025

In this article, we'll look at different ways to split and parse strings in Python. Let's understand this with the help of a basic example:


Output
geeks
for
geeks

Let's understand different methods to split and parse a string in Python.

Using re.split()

re.split() uses regular expressions to split a string based on patterns, making it highly flexible for complex cases with multiple delimiters.


Output
['geeks', 'for', 'geeks']

Using map()

We can use the map() function to split a string into parts and then change each part, like turning all words into uppercase. It helps us process each piece of the string easily.


Output
GEEKS
FOR
GEEKS

Using partition

partition()method splits a string into three parts. Part before the first delimiter, the delimiter itself, and the part after it. It’s useful when we only need to split at the first occurrence of a specific character.


Output
geeks
for,geeks
Comment
Article Tags:
Article Tags: