The regex I use when I want to be precise is "\r\n?|\n"
.
When I’m not concerned about consistency or empty lines, I use "[\r\n]+"
, I imagine it makes my programs somewhere in the order of 0.2% faster.
More Related Contents:
- Take first some character of string but if particular character will come consider that character also
- How to extract numbers from a string in Python?
- Is it worth using Python’s re.compile?
- Extract part of a regex match
- Regular expression matching a multiline block of text
- How can I do multiple substitutions using regex?
- How to match any string from a list of strings in regular expressions in python?
- How to timeout function in python, timeout less than a second
- How to share conda environments across platforms
- Split string based on regex
- How to add a timeout to a function in Python
- Find all Chinese text in a string using Python and Regex
- How to use re to find consecutive, repeated chars
- Python – re.findall returns unwanted result
- Why Does a Repeated Capture Group Return these Strings?
- Splitting out the output of ps using Python
- How to use regex to find all overlapping matches
- How can a recursive regexp be implemented in python?
- Python regular expression pattern * is not working as expected
- Split string at every position where an upper-case word starts
- FutureWarning: The default value of regex will change from True to False in a future version
- Why does this take so long to match? Is it a bug?
- Regex matching – why does this not match and return None?
- How do I verify that a string only contains letters, numbers, underscores and dashes? [duplicate]
- Python regex findall
- Python regex: matching a parenthesis within parenthesis
- Regexp finding longest common prefix of two strings
- Splitting a math expression string into tokens in Python
- Python multiprocessing linux windows difference
- Download all pdf files from a website using Python