[英]Regex to find words (hash) with numbers and letters
I have a set of strings and some of them has "words" with numbers and letters, for example:我有一组字符串,其中一些有带有数字和字母的“单词”,例如:
Revert Push Diamond tick mark classes to Eclipse This reverts commit 4086b8666cdc839b5ec7e7bfff0ae1b9695542ff .......将菱形刻度标记类恢复到 Eclipse 这将恢复提交 4086b8666cdc839b5ec7e7bfff0ae1b9695542ff .......
Is there some regex expression to remove these words (hash)?是否有一些正则表达式可以删除这些单词(哈希)?
You could look for sequences of hex characters delimited with whitespace of a required length, eg between 30
and 50
characters.您可以查找以所需长度的空格分隔的十六进制字符序列,例如30
到50
字符之间。 For example:例如:
import re
text = """Revert Push Diamond tick mark classes to Eclipse This reverts commit
4086b8666cdc839b5ec7e7bfff0ae1b9695542ff .......
Another test
48a8b89d9f8e80a938f8ab487de09ff
"""
for hash in re.findall(r'\s+([0-9a-fA-F]{30,50})\s+', text):
print(hash)
Would display:会显示:
4086b8666cdc839b5ec7e7bfff0ae1b9695542ff
48a8b89d9f8e80a938f8ab487de09ff
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.