About 254,000 results
Open links in new tab
  1. regex - Get the string within brackets in Python - Stack Overflow

    @user3015703 In a character set you don't need to escape special characters, except for '-' or ']'. To include a dash you can either precede it with a slash, or make it the first or last character in …

  2. python - How to use a variable inside a regular expression - Stack …

    May 30, 2023 · This only works because we are using a raw-string (the regex is preceded by 'r'), otherwise we must write "\\\\boundary" in the regex (four backslashes). Additionally, without '\r', …

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

    Jan 17, 2024 · 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 …

  4. regex - How to use regexp on file, line by line, in Python - Stack …

    Apr 25, 2020 · Here is my regexp: f\\(\\s*([^,]+)\\s*,\\s*([^,]+)\\s*\\) I'd have to apply this on a file, line by line. The line by line is OK, simple reading from file, and a loop ...

  5. Python - Using regex to find multiple matches and print them out

    Oct 11, 2011 · Instead of using re.search use re.findall it will return you all matches in a List. Or you could also use re.finditer (which i like most to use) it will return an Iterator Object and you …

  6. python - How to select columns from dataframe by regex - Stack …

    Mar 10, 2014 · @FarazMasroor search for ^d.*; ^ looks for proceeding regex that starts the string. But I think a more accurate regex in this case -- assuming numbers follow "d" -- is ^d\d+ where …

  7. Python dictionary search values for keys using regular expression

    May 29, 2012 · I am trying to implement to search for a value in Python dictionary for specific key values (using regular expression as a key). Example: I have a Python dictionary which has …

  8. Python: How to use RegEx in an if statement? - Stack Overflow

    import re if re.match(regex, content): blah.. You could also use re.search depending on how you want it to match.

  9. python - How to filter rows in pandas by regex - Stack Overflow

    Mar 11, 2013 · Using Python's built-in ability to write lambda expressions, we could filter by an arbitrary regex operation as follows: import re # with foo being our pd dataframe …

  10. python - Regular Expressions: Search in list - Stack Overflow

    Dec 20, 2024 · For Python 2.x developers, filter returns a list already. In Python 3.x filter was changed to return an iterator so it has to be converted to list (in order to see it printed out …

Refresh