开发者

How to match non-printable characters in a python regular expression?

开发者 https://www.devze.com 2023-02-21 17:13 出处:网络
How do you match non-printable characters in a p开发者_运维百科ython regular expression? In my case I have a string that has a combination of printable and non-printable characters.

How do you match non-printable characters in a p开发者_运维百科ython regular expression? In my case I have a string that has a combination of printable and non-printable characters.

Example String: "Det 3 @ NYY 5 ?7" where the ? is either 0x7f or 0x80.

In the above example I need to match 0x7f or 0x80. How do I specify this in a python regex?


Use a character range.

'[\x7f\x80]'


Maybe you can try

[^[:print:]]

for non-printable.

0

精彩评论

暂无评论...
验证码 换一张
取 消