In this specific case:

val[val.index('*')+1:]

Find the first occur position of *, and take a slice from there.

or:

val.split('*', 1)[-1]

The tells to split string only once with delimiter, if you want everything after the first *.

Answer from cizixs on Stack Overflow
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-index-and-slice-strings-in-python-3
How To Index and Slice Strings in Python | DigitalOcean
September 29, 2025 - Learn how to index and slice strings in Python 3 with step-by-step examples. Master substring extraction, negative indexing, and slice notation.
🌐
Built In
builtin.com › software-engineering-perspectives › python-substring-indexof
5 Ways to Find the Index of a Substring in Python | Built In
Below is a summary of what you need to remember about each Python string method. str.find(), str,index(): These return the lowest index of the substring.
🌐
Programiz
programiz.com › python-programming › methods › string › index
Python String index()
If substring exists inside the string, it returns the lowest index in the string where substring is found.
🌐
GeeksforGeeks
geeksforgeeks.org › python › find-the-index-of-a-substring-in-python
Find the Index of a Substring in Python - GeeksforGeeks
July 23, 2025 - The substring 'for' is found at index 6. The re.search() in Python's re module can be used to locate the first occurrence of a pattern in a string.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-substring-a-string-in-python
How to Substring a String in Python
January 3, 2020 - Index -1 represents the last character of the string, -2 represents the second to last character and so on. ... 5. Get a substring which contains all characters except the last 4 characters and the 1st character**
🌐
Medium
medium.com › better-programming › 5-ways-to-find-the-index-of-a-substring-in-python-13d5293fc76d
5 Ways to Find the Index of a Substring in Python | by Indhumathy Chelliah | Better Programming
September 2, 2021 - Photo by Maulik Sutariya on Unsplash · str.find() str.rfind() str.index() str.rindex() re.search() str.find() returns the lowest index in the string where the substring sub is found within the slice s[start:end]. It returns -1 if the sub is ...
🌐
Vultr Docs
docs.vultr.com › python › standard-library › str › index
Python str index() - Find Substring Index | Vultr Docs
November 26, 2024 - This code finds the index of the substring "welcome" in the string "Hello, welcome to Python.". It prints 7, indicating that "welcome" starts at index 7. Prepare to catch exceptions when the substring isn’t found in the string. Use a try...except block to handle ValueError, which is raised by ...
Find elsewhere
🌐
Python Tutorial
pythontutorial.net › home › python string methods › python string index()
Python String index(): Locating the Index of a Substring in a String
December 28, 2020 - The following example uses the index() method to find the substring 'Python' in the string 'Python will, Python will rock you.' within the slice str[1:]:
🌐
GeeksforGeeks
geeksforgeeks.org › python-string-index-method
Python String index() Method - GeeksforGeeks
May 2, 2025 - This code demonstrates how to find the index of a substring within a specific range of a string using the index() method with optional start and end parameters. ... We specify start=10 and end=25, so index() searches between these positions.
🌐
Linode
linode.com › docs › guides › how-to-slice-and-index-strings-in-python
How to Slice and Index Strings in Python | Linode Docs
January 28, 2022 - The following example generates a substring consisting of the second half of the parent string. The length of the initial string is calculated using len and divided by two to determine the midpoint. The midpoint becomes the start index for the slicing operation. This is a good example of how an index can be represented by a fairly complex expression. ... The Python ...
🌐
LearnDataSci
learndatasci.com › solutions › python-substring
Quickly Substring a String in Python – LearnDataSci
Using this approach will return a substring with everything that comes before the end index. See below for an example of this using example_string (note that this produces the same result as example_string[0:7] in the intro): example_string = 'example_string' example_string[:7] ... Notice that the second 'e' is at index 6, so using an end point of 7, Python returns a substring containing everything that comes before.
🌐
datagy
datagy.io › home › python posts › python strings › python: find an index (or all) of a substring in a string
Python: Find an Index (or all) of a Substring in a String • datagy
December 20, 2022 - We include the index position of that number if the substring that’s created by splitting our string from that index onwards, begins with our letter · We get a list returned of all the instances where that substring occurs in our string · In the final section of this tutorial, you’ll learn how to build a custom function to return the indices of all substrings in our Python string.
🌐
Sentry
sentry.io › sentry answers › python › extract a substring from a string in python
Python Substring Extraction With Slice Notation | Sentry
2 weeks ago - We can omit the start value to begin at index 0 or the end value to continue until the end of the string. ... my_string = "Hello world!" substring = my_string[1:5] # will be "ello" substring = my_string[:5] # will be "Hello" substring = my_string[6:] # will be "world!" We can also use regular expressions to extract a substring using the re module in Python.
🌐
Tutorialspoint
tutorialspoint.com › python › string_index.htm
Python String index() Method
Welcome to Tutorialspoint." str2 ... above program - ... The python string index() method returns the index where the substring is found within the range of the starting and ending index that is specified....
🌐
IONOS
ionos.com › digital guide › websites › web development › python string index
How to find the position of a substring with Python string index
January 23, 2024 - string = "Peter Piper picked a peck of pickled peppers." print("The string to check is ", string) while(True): sub = input("substring input: ") try: print("the index is: ", string.index(sub)) except: print("The substring is not included :/")Python · This example searches for a substring in a string. It then outputs whether the substring is contained in the string and, if so, at which index. In this case, the string we’re searching is pre­de­ter­mined, but the substring is re-entered by the user each time.
🌐
Medium
medium.com › @muraliairody › find-and-index-of-string-6c50c819273c
Find and Index of String. Sure! Let’s dive into index() and… | by Murali | Medium
October 24, 2025 - Returns the lowest index where substring is found. Returns -1 if the substring is not found. Optional start and end parameters let you search within a slice of the string. ... text = "Hello Python" print(text.find("Python")) # 6 print(text....
🌐
Real Python
realpython.com › lessons › index-python-substring
Use .index() to Get the Location of the Substring (Video) – Real Python
00:25 It is aptly named .index(). So you can say text_lower.index() and then pass it as an argument the substring, and then Python will return to you the index position of the first letter of the first occurrence of the substring in your string.
Published   April 4, 2023