About 2,030,000 results
Open links in new tab
  1. Python - All occurrences of substring in string - GeeksforGeeks

    Jul 12, 2025 · A substring is a contiguous occurrence of characters within a string. Identifying all instances of a substring is important for verifying various tasks. In this article, we will check all …

  2. How to find all occurrences of a substring? - Stack Overflow

    Python has string.find() and string.rfind() to get the index of a substring in a string. I'm wondering whether there is something like string.find_all() which can return all found indexes (not only the first …

  3. Python String find () Method - W3Schools

    The find() method returns -1 if the value is not found. The find() method is almost the same as the index() method, the only difference is that the index() method raises an exception if the value is not …

  4. Python | Ways to find nth occurrence of substring in a string

    Jul 12, 2025 · Given a string and a substring, write a Python program to find the n th occurrence of the string. Let's discuss a few methods to solve the given task. Get Nth occurrence of a substring in a …

  5. Python - Replace all Occurrences of a Substring in a String

    Oct 31, 2025 · Given a string and a target substring, the task is to replace all occurrences of the target substring with a new substring. For Example: Input: "python java python html python" Replace …

  6. Find All Occurrences of a Substring in a String in Python

    Jun 29, 2022 · To find all the occurrences of a substring in a string in python using the startswith() method, we will use the following steps. First, we will find the length of the input string and store it in …

  7. Python - Characters Index occurrences in String - GeeksforGeeks

    Apr 23, 2023 · Sometimes, while working with Python Strings, we can have a problem in which we need to check for all the characters indices. The position where they occur. This kind of application can …

  8. python - Find all the occurrences of a character in a string - Stack ...

    Find all the occurrences of a character in a string Asked 13 years, 5 months ago Modified 1 year, 6 months ago Viewed 106k times

  9. Find the nth occurrence of substring in a string - Stack Overflow

    This seems like it should be pretty trivial, but I am new at Python and want to do it the most Pythonic way. I want to find the index corresponding to the n'th occurrence of a substring within a string. …

  10. Python String Search and Replace: in, .find (), .index (), .count ...

    Mar 31, 2026 · The fix is straightforward: use the right tool for the job. We rely on the in operator for existence checks, .find() /.index() for positions, .count() for tallies, and .replace() for …