About 702,000 results
Open links in new tab
  1. python - Check if string matches pattern - Stack Overflow

    From the docs on re.match: If zero or more characters at the beginning of string match the regular expression pattern. I just spent like 30 minutes trying to understand why I couldn't match …

  2. Python match a string with regex - Stack Overflow

    Oct 10, 2013 · I need a python regular expression to check if a word is present in a string. The string is separated by commas, potentially. So for example, line = 'This,is,a,sample,string' I want …

  3. python's re: return True if string contains regex pattern

    I have a regular expression like this: regexp = u'ba[r|z|d]' Function must return True if word contains bar, baz or bad. In short, I need regexp analog for Python's 'any-string' in 'text' How can I

  4. python - Checking whole string with a regex - Stack Overflow

    30 There are a couple of options in Python to match an entire input with a regex. Python 2 and 3 In Python 2 and 3, you may use

  5. python - How can I make a regex match the entire string ... - Stack ...

    How can I make a regex match the entire string? Asked 8 years, 5 months ago Modified 3 years, 2 months ago Viewed 129k times

  6. Python wildcard search in string - Stack Overflow

    Jul 11, 2012 · import fnmatch lst = ['this','is','just','a','test'] filtered = fnmatch.filter(lst, 'th?s') If you want to allow _ as a wildcard, just replace all underscores with '?' (for one character) or * (for …

  7. regex - Python extract pattern matches - Stack Overflow

    Mar 11, 2013 · If this is the case, having span indexes for your match is helpful and I'd recommend using re.finditer. As a shortcut, you know the name part of your regex is length 5 …

  8. python - Return string with first match for a regex, handling case ...

    Return string with first match for a regex, handling case where there is no match Asked 9 years, 5 months ago Modified 2 years, 11 months ago Viewed 337k times

  9. regex - How can I find all matches to a regular expression in …

    Jan 17, 2024 · 1 If you are interested in getting all matches (including overlapping matches, unlike @Amber's answer), there is a new library called REmatch which is specifically designed to …

  10. Checking whether a string starts with XXXX - Stack Overflow

    Jan 10, 2012 · I would like to know how to check whether a string starts with "hello" in Python. In Bash I usually do: