Python: POSIX character class in regex?
问题 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} 回答1: 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} : [\x20-\x7E]{10} See demo Alternatively, you can use Matthew Barnett regex module that claims to support POSIX character classes ( POSIX character