About 18,500,000 results
Open links in new tab
  1. python - find position of a substring in a string - Stack Overflow

    May 13, 2012 · We use a simple search to find the position of the "is": >>> match = re.search(r"[^a-zA-Z](is)[^a-zA-Z]", mystr) This returns the first match as a match object.

  2. Find the Index of a Substring in Python - GeeksforGeeks

    Nov 19, 2024 · To get index of a substring within a Python string can be done using several methods such as str.find(), str.index(), and even regular expressions. Each approach has its …

  3. Python find() – How to Search for a Substring in a String

    Jul 25, 2022 · The find() string method is built into Python's standard library. It takes a substring as input and finds its index - that is, the position of the substring inside the string you call the …

  4. Python String find (): How to Find a Substring in a String …

    The find() is a string method that finds a substring in a string and returns the index of the substring. The following illustrates the syntax of the find() method: str .find ( sub [, start[, end] ]) …

  5. Search for a string in Python (Check if a substring is included/Get …

    May 7, 2023 · You can get the position of a given substring in the string with the find() method of str. Built-in Types - str.find() — Python 3.11.3 documentation If the substring specified as the …

  6. Find() Function in Python – Find a position of substring

    In this section we will be learning how to find the position of the substring with the help of Find() function in python with an example. If the substring found then starting position is returned. If …

  7. Python: Find an Index (or all) of a Substring in a String

    Sep 23, 2021 · In this post, you’ll learn how to find an index of a substring in a string, whether it’s the first substring or the last substring. You’ll also learn how to find every index of a substring …

  8. How to get the position of a character in Python? - Stack Overflow

    Feb 19, 2010 · There are two string methods for this, find() and index(). The difference between the two is what happens when the search string isn't found. find() returns -1 and index() raises …

  9. Python String find() Method - PyTutorial

    Oct 18, 2024 · The find() method in Python is a versatile tool for locating substrings within strings. It allows you to search with precision by specifying a range and provides a straightforward way …

  10. 5 Ways to Find the Index of a Substring in Python | Built In

    Oct 1, 2024 · How to Find the Index of a Substring in Python. Complete guide on using string methods and regexes in Python to find the index of a substring. Learn all five methods.

Refresh