Same as in Perl, but with a backslash instead of the dollar for accessing groups:
s = "0123456789"*100 # test string
import re
print re.sub("(.{64})", "\\1\n", s, 0, re.DOTALL)
re.DOTALL
is the equivalent to Perl’s s/
option.
More Related Contents:
- RegEx for Multi-Words Without Numbers and Any Special Characters
- What is this pattern “\\s*\\^++\\s*” used for? [duplicate]
- Regular expression to match balanced parentheses
- How do I deal with special characters like \^$.?*|+()[{ in my regex?
- How to capture multiple repeated groups?
- Fast punctuation removal with pandas
- Python: How to match nested parentheses with regex?
- How do you validate a URL with a regular expression in Python?
- Regular expression to enforce complex passwords, matching 3 out of 4 rules
- Regular expression for a string that does not start with a sequence
- Regex: Specify “space or start of string” and “space or end of string”
- Regex – Does not contain certain Characters
- Regex to match all permutations of {1,2,3,4} without repetition
- Notepad++ Find/Replace number with Increment Value
- Using BeautifulSoup to find a HTML tag that contains certain text
- Mongodb match accented characters as underlying character
- Have HTML5’s a inputs pattern attribute ignore case
- Regular Expression to match cross platform newline characters
- JSLint reports “Insecure ^” for my regex — what does that mean?
- Variable-Width Lookbehind Issue in Python
- Re.sub not working for me
- Does Flask support regular expressions in its URL routing?
- Can extended regex implementations parse HTML?
- How to get Vim to highlight non-ascii characters?
- Regexp for subdomain
- Regexp finding longest common prefix of two strings
- Splitting a math expression string into tokens in Python
- Bash – Regex for HTML contents
- Extracting text after last period in string [duplicate]
- Download all pdf files from a website using Python