About 520,000 results
Open links in new tab
  1. Python: Find pattern in a string - Stack Overflow

    I am trying to find a way to match a pattern p in a string s in python.

  2. python - Check if string matches pattern - Stack Overflow

    If you need to search a pattern in a single string, then there's no need to compile it since re.search, re.match etc. all make calls to _compile method anyway. However, if you need to …

  3. python - How to find a pattern in a string - Stack Overflow

    check_string = 'I have a string 09A4N5' I have to find the position of '09A4N5' which could be any other string in a similar format. I tried with the regular expression and was able to find the get …

  4. regex - Python extract pattern matches - Stack Overflow

    Mar 11, 2013 · As a shortcut, you know the name part of your regex is length 5 and the is valid is length 9, so you can slice the matching text to extract the name. Note - In your example, it …

  5. python - Find a substring in a string and returning the index of the ...

    Python is a "batteries included language" there's code written to do most of what you want already (whatever you want).. unless this is homework :) find returns -1 if the string cannot be found.

  6. How can I find all matches to a regular expression in Python?

    Jan 17, 2024 · 562 When I use the re.search() function to find matches in a block of text, the program exits once it finds the first match in the block of text. How do I do this repeatedly …

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

    Follow-up: How to find all occurrences of a substring in a string while ignore some characters in Python?

  8. python - Find the indexes of all regex matches? - Stack Overflow

    re.finditer(pattern, string[, flags]) Return an iterator yielding MatchObject instances over all non-overlapping matches for the RE pattern in string. The string is scanned left-to-right, and …

  9. Search for a pattern in a string in python - Stack Overflow

    Python strings have the in operator; you can check if str1 is a substring of str2 using str1 in str2. You can split a string into a list of substrings based on a token. "a*b*c".split("*") is ["a","b","c"]. …

  10. How can I find the first occurrence of a sub-string in a python …

    Additional knowledge: rfind and rindex: In general, find and index return the smallest index where the passed-in string starts, and rfind and rindex return the largest index where it starts Most of …