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
🌐
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.
🌐
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 - Part after best is stored in result. If best isn't found, an empty string is returned. find() method is used to locate the starting index of a substring in a string.
🌐
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
August 27, 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

🌐
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 ...
🌐
Note.nkmk.me
note.nkmk.me › home › python
Extract a Substring from a String in Python (Position, Regex) | note.nkmk.me
April 29, 2025 - In Python, you can use regular expressions (regex) with the re module of the standard library. ... Use re.search() to extract the first substring that matches a regex pattern. Pass the regex pattern as the first argument and the target string as the second argument. import re s = '012-3456-7890' print(re.search(r'\d+', s)) # <re.Match object; span=(0, 3), match='012'> ... In regex, \d matches a digit character, while + matches one or more occurrences of the preceding pattern.
🌐
Python Examples
pythonexamples.org › python-get-substring-after-specific-character
Python - Get substring after specific character
In this tutorial, you will learn how to get the substring after a specific character in a string in Python, using string find() method and string slicing, with examples.
🌐
freeCodeCamp
freecodecamp.org › news › python-substring-how-to-slice-a-string
Python Substring – How to Slice a String
July 27, 2021 - In this example, you will slice the last 4 characters from the string. Here you use the negative index to start slicing from the end of the string. ... The output will be ‘camp’. You can slice the string with steps after indicating a start-index and stop-index. By default, the step is 1 but in the following example, the step size is 2. string = "welcome to freecodecamp" print(string[::2]) The output will be ‘wloet fecdcm’. Sometimes you want to check if a substring is present in a string.
Find elsewhere
🌐
Tutorial Gateway
tutorialgateway.org › python-substring
Python substring
March 26, 2025 - Before First Character : = 22 Before Second Character : = 30 After Second Character : = 55 ------------ Before First Character : = 22 After First Character : = 30:55 ------------ Before Second Character : = 22:30 After Second Character : = 55 · This example shows how to return a substring after a character.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-remove-after-substring-in-string
Python - Remove after substring in String - GeeksforGeeks
July 15, 2025 - For example we are given a string s="Hello, this is a sample string" we need to remove the part of string after a particular substring including the part of substring suppose the given substring is "sample" so we need to remove the part from the substring from the string so the output string will become "Hello, this is a".
🌐
ReqBin
reqbin.com › code › python › h73zla88 › python-substring-example
How do I get a substring from a string in Python?
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.
🌐
Finxter
blog.finxter.com › python-split-string-after-delimiter
Python | Split String After Delimiter – Be on the Right Side of Change
The partition() method searches for a separator substring and returns a tuple with three strings: (1) everything before the separator, (2) the separator itself, and (3) everything 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 then Python facilitates you with the removeprefix method that allows you to remove the substring that comes before a specified substring.
🌐
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)

🌐
Quora
quora.com › How-do-you-extract-a-character-from-a-string-in-Python
How to extract a character from a string in Python - Quora
Answer (1 of 4): I don’t program in Python, but this is how I did it in Plain English. Plain English looks like pseudocode and is easily translated into any equally powerful programming language. The String I started by defining my test data as a global variable with the names of six “character...
🌐
IONOS
ionos.com › digital guide › websites › web development › python substring
How to create and edit Python substrings
July 19, 2023 - The syntax of slicing in Python looks like this: ... First, we created a string called “s”. In the second line of the code example, you can see how slicing works. After the name of the string, there are square brackets. Inside the brackets, you’ll find the start index 0 followed by a colon and then the end index 6. The “result” variable then stores a substring of “s”, which consists of the characters from the 0th index up to and including the 5th index.
🌐
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...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-extract-string-after-nth-occurrence-of-k-character
Python - Extract String after Nth occurrence of K character - GeeksforGeeks
April 26, 2023 - 2-Initialize a variable index to 0 and a variable count to 0. 3-While count is less than N: a. Find the index of the K character in test_str starting from the index position using the find() method. b. If the find() method returns -1, exit the loop. c. Otherwise, increment count by 1 and update the value of index to index + 1. 4-Extract the substring from test_str starting from the index position to the end of the string using slicing. 5-Print the extracted substring. ... # Python3 code to demonstrate working of # Extract String after Nth occurrence of K character # Using find() and slicing #
🌐
Python
docs.python.org › 3 › library › string.html
Common string operations — Python 3.14.3 documentation
It is exposed as a separate function for cases where you want to pass in a predefined dictionary of arguments, rather than unpacking and repacking the dictionary as individual arguments using the *args and **kwargs syntax. vformat() does the work of breaking up the format string into character data and replacement fields.
🌐
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)
🌐
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 - Python offers different ways to create substrings depending on the task. The examples in the sections below demonstrate various problems and walk through the code syntax to explain the behavior. To create a substring using slicing, refer to the following code: quote = "Toto, I have a feeling we're not in Kansas anymore." print(quote[6:22]) The code prints a substring between two characters ...