About 241,000 results
Open links in new tab
  1. Does Python have a string 'contains' substring method?

    Aug 9, 2010 · 571 Does Python have a string contains substring method? 99% of use cases will be covered using the keyword, in, which returns True or False:

  2. how to find whether a string is contained in another string

    str.find() and str.index() are nearly identical. the biggest difference is that when a string is not found, str.index() throws an error, like the one you got, while str.find() returns -1 as others' have posted. …

  3. python - How to match a substring in a string, ignoring case - Stack ...

    I'm looking for ignore case string comparison in Python. I tried with: if line.find('mandy') >= 0: but no success for ignore case. I need to find a set of words in a given text file. I am read...

  4. How do I check if a given Python string is a substring of another one ...

    I have two strings and I would like to check whether the first is a substring of the other. Does Python have such a built-in functionality?

  5. python - How to check if a string is a substring of items in a list of ...

    How to check if a string is a substring of items in a list of strings Asked 14 years, 10 months ago Modified 3 years, 3 months ago Viewed 1.9m times

  6. Determining how many times a substring occurs in a string in Python

    I am trying to figure out how many times a string occurs in a string. For example: nStr = '000123000123' Say the string I want to find is 123. Obviously it occurs twice in nStr but I am having tro...

  7. Check if multiple strings exist in another string - Stack Overflow

    I found this question from a link from another closed question: Python: How to check a string for substrings from a list? but don't see an explicit solution to that question in the above answers.

  8. How do I get a substring of a string in Python? - Stack Overflow

    Aug 31, 2016 · I want to get a new string from the third character to the end of the string, e.g. myString[2:end]. If omitting the second part means 'to the end', and if you omit the first part, does it …

  9. python - Filter pandas DataFrame by substring criteria - Stack Overflow

    More Options for Partial String Matching: np.char.find, np.vectorize, DataFrame.query. In addition to str.contains and list comprehensions, you can also use the following alternatives. np.char.find …

  10. Check if substring is in a list of strings? - Stack Overflow

    May 5, 2013 · I have found some answers to this question before, but they seem to be obsolete for the current Python versions (or at least they don't work for me). I want to check if a substring is contained …