How can I search for, say, a sequence of 10 isprint
characters in a given string in Python?
With GNU grep, I would simply do grep [[:print:]]{10}
How can I search for, say, a sequence of 10 isprint
characters in a given string in Python?
With GNU grep, I would simply do grep [[:print:]]{10}
Copyright © 2021 Jogjafile Inc.
Since POSIX is not supported by Python
re
module, you have to emulate it with the help of character class.You can use the one from the regular-expressions.info and add a limiting quantifier
{10}
:See demo
Alternatively, you can use Matthew Barnett regex module that claims to support POSIX character classes (POSIX character classes are supported.).