The easiest way is probably just to split on your target word:

my_string = "Hello, Python world. I'm a beginner"
print(my_string.split("world", 1)[1])

split takes the word (or character) to split on and optionally a limit to the number of splits.

In this example, split on "world" and limit it to only one split.

Answer from Joran Beasley on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-get-the-string-after-occurrence-of-given-substring
Python | Get the string after occurrence of given substring - GeeksforGeeks
July 11, 2025 - To extract the portion of a string that occurs after a specific substring partition() method is an efficient and straightforward solution. It splits the string into three parts: the portion before the substring, the substring itself, and the ...
Discussions

How to extract a substring after a character / delimiter on Python
Use a regular expression that extracts the 4 characters after the comma. More on reddit.com
🌐 r/dataanalysis
9
1
October 2, 2022
Removing a all specific text after a word in Python.
A site I wish someone had shown me when I was learning... Drop your code in here and step through it ("Visualize Execution") and watch what it's doing. See if you can figure it out. If not feel free to come back :) https://pythontutor.com/visualize.html More on reddit.com
🌐 r/learnpython
23
9
July 3, 2022
🌐
Linux Hint
linuxhint.com › substring-after-character-python
Python Substring After Character – Linux Hint
Another efficient way of substring after the character in Python, the “index()” method can be used.
🌐
Reddit
reddit.com › r/dataanalysis › how to extract a substring after a character / delimiter on python
r/dataanalysis on Reddit: How to extract a substring after a character / delimiter on Python
October 2, 2022 -

Hi All

I am trying to extract the year from the below column on Python.

I cannot use the partition method & split function as it does not seems to exist for me.

Any idea how else can I extract only the years

My Python version is 3.10.4

🌐
GeeksforGeeks
geeksforgeeks.org › python › python-remove-after-substring-in-string
Python - Remove after substring in String - GeeksforGeeks
July 15, 2025 - DSA Python · Data Science · NumPy · Pandas · Practice · Django · Flask · Last Updated : 15 Jul, 2025 · Removing everything after a specific substring in a string involves locating the substring and then extracting only the part of the string that precedes it.
🌐
Finxter
blog.finxter.com › home › learn python blog › python | split string after character
Python | Split String after Character - Be on the Right Side of Change
March 8, 2023 - Note that, in the following example, ... the substring after the character occurs. # Input text = "Lorem ipsum amet dolor sit s amet consectetur adipisametcing. amets" split_char = "s" # Expected Output: ['Lorem ips', 'um amet dolor s', 'it s', ' amet cons', 'ectetur adipis', 'ametcing. amets'] Suppose you are given the following string: “Welcome to the world of Python“. You have ...
🌐
Python Examples
pythonexamples.org › python-get-substring-after-specific-character
Python - Get substring after specific character
To get the substring after a specific character in a string in Python, you can first find the index of the specified character, and then slice the string from index+1 to the end of the string.
Find elsewhere
🌐
Tutorial Gateway
tutorialgateway.org › python-substring
Python substring
May 25, 2019 - For this, we are using the built-in function called Python Split string. Here, we used the split function to split the given text into two substrings using space and assigned those splitter strings to two variables. c = 'Tutorial Gateway' first, second = c.split(' ') print('Before Character space = ', first) ... In this example, we use this split function to return the sentence before and after the character.
🌐
pythontutorials
pythontutorials.net › blog › how-to-get-a-string-after-a-specific-substring
How to Get a String After a Specific Substring in Python: Step-by-Step Tutorial — pythontutorials.net
Slice the original string from this end position to the end to get the text after the substring. ... text = "Hello, my name is Alice. I love Python!" substring = "name is " # Substring to search for # Step 1: Find the index of the substring ...
🌐
freeCodeCamp
freecodecamp.org › news › python-substring-how-to-slice-a-string
Python Substring – How to Slice a String
July 27, 2021 - Python provides different ways and methods to generate a substring, to check if a substring is present, to get the index of a substring, and more.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Extract a Substring from a String in Python (Position, Regex) | note.nkmk.me
April 29, 2025 - This article explains how to extract a substring from a string in Python. You can extract a substring by specifying its position and length, or by using regular expression (regex) patterns. Extract a ...
🌐
freeCodeCamp
freecodecamp.org › news › how-to-substring-a-string-in-python
How to Substring a String in Python
January 3, 2020 - Python offers many ways to substring a string. This is often called "slicing". Here is the syntax: string[start:end:step] Where, start: The starting index of the substring. The character at this index is included in the substring. If start is not in...
🌐
Finxter
blog.finxter.com › home › learn python blog › python | split string after delimiter
Python | Split String After Delimiter - Be on the Right Side of Change
November 28, 2022 - The partition() method searches ... after it. It then returns a tuple with the same three strings. Approach: We have used the partition method and used “-” as a separator. As we only need the substring before the delimiter, we have used the index of the required substring on the returned tuple and just printed the third element of the tuple (everything before the separator). ... If you are using Python 3.9 or above ...
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › XPath › Functions › substring-after
substring-after - XPath | MDN
January 31, 2025 - The substring-after function returns a string that is the rest of a given string after a given substring.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-till-substring
Python - String till Substring - GeeksforGeeks
July 12, 2025 - We can manually iterate through the string and stop when we encounter the substring. ... s = "learn-python-with-gfg" sub = "-" res = "" for c in s: # Iterating through each character in the string if c in sub: # Stop when the substring is found break res += c # Add characters to the result print(res)
🌐
Stack Overflow
stackoverflow.com › questions › 24986504 › find-the-last-substring-after-a-character
python - Find the last substring after a character - Stack Overflow
I know many ways how to find a substring: from start index to end index, between characters etc., but I have a problem which I don't know how to solve: I have a string like for example a path: fold...
🌐
Sentry
sentry.io › sentry answers › python › extract a substring from a string in python
Python Substring Extraction With Slice Notation | Sentry
July 3, 2026 - Extract substrings from Python strings using slice notation with [start:end] indexes, or use re.search() with regex patterns for matching specific formats
🌐
PhoenixNAP
phoenixnap.com › home › kb › devops and development › how to substring a string in python
How to Substring a String in Python | phoenixNAP KB
November 27, 2025 - The code prints a substring between two characters at the provided indexes. Note: Learn how to perform string repetition in Python using several different methods.
🌐
Reddit
reddit.com › r/learnpython › removing a all specific text after a word in python.
r/learnpython on Reddit: Removing a all specific text after a word in Python.
July 3, 2022 -

Hello,

I want to remove the entire substring after a particular word in Python.

For instance, if the word is "Excerpt," all text after the word would be removed.

However, my code is not accomplishing that task.

If the word exists in the string, I would find the index of it.

After that, I would subtract the len(text)-index of the word, which should point to the word.

Am I not returning from 0-index of the word, hence removing the word, and everything after the word.

What is the issue with my code?

str1 = 'Excerpt'
if str1 in text.split():
strLength = text.find(str1)
a = text[0:len(text)-strLength]
print(a)

🌐
ReqBin
reqbin.com › code › python › h73zla88 › python-substring-example
How do I get a substring from a string in Python?
December 25, 2022 - To get a substring from a string in Python, you can use the slicing operator string[start:end:step]. The slice operator returns the part of a string between the "start" and "end" indices.