About 52,900 results
Open links in new tab
  1. python - Structural pattern matching using regex - Stack Overflow

    Jan 12, 2022 · For regex 1, 2 and 3, I've tried string regex patterns and also re.compile objects but it doesn't seem to work. I have been trying to find examples of this over the internet but can't seem to …

  2. Best way to strip punctuation from a string - Stack Overflow

    Dec 1, 2016 · Just as an update, I rewrote the @Brian example in Python 3 and made changes to it to move regex compile step inside of the function. My thought here was to time every single step …

  3. How to remove empty lines with or without whitespace

    Oct 17, 2023 · One liner to remove empty lines (without whitespace) is this . Question headline could potentially be changed to 'Remove empty lines with whitespace only in python'.

  4. How to use regex with optional characters in python?

    Mar 27, 2012 · 1 Read up on the Python RegEx library. The link answers your question and explains why. However, to match a digit followed by more digits with an optional decimal, you can use

  5. regex - Learning Regular Expressions - Stack Overflow

    Aug 7, 2008 · Regex Syntax Summary How Regexes Work JavaScript Regular Expressions Footnote †: The statement above that . matches any character is a simplification for pedagogical purposes that is …

  6. regex - Python and "re" - Stack Overflow

    A tutorial I have on Regex in python explains how to use the re module in python, I wanted to grab the URL out of an A tag so knowing Regex I wrote the correct expression and tested it in my regex …

  7. pandas - str.extract () with regex - Stack Overflow

    Dec 17, 2021 · I need to split a column into two using regex and str.extract() (assuming this is best) df = pd.DataFrame({ 'Product': ['Truly Mix 2/12Pk Cans - 12Z', ...

  8. Phone Number Regular Expression (Regex) in Python

    Mar 8, 2012 · In defense of Dive into Python, the author states explicitly that he's parsing American phone numbers, and lists the formats in which the phone number can occur.

  9. while-loop in python as long as regex matches - Stack Overflow

    Jan 18, 2018 · 4 Ok, I'm aware that it's probably not the best way to edit a string with regex expressions in loops. Just for the sake of interest: How would I have to build a loop, that executes a regex pattern …

  10. python - Regex – re.sub explanation - Stack Overflow

    Oct 3, 2019 · In a regex, parenthesis are a capture group. This means that you want to save one particular part of a match, and use it later. \g<1> is a way of saying "the first capture group", \g<2> is …