简体   繁体   English

正则表达式查找带有数字和字母的单词(哈希)

[英]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.您可以查找以所需长度的空格分隔的十六进制字符序列,例如3050字符之间。 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.

相关问题 使用正则表达式查找不是在句子开头的大写字母 - Find words with capital letters not at start of a sentence with regex 正则表达式:查找所有带有某些字母但没有其他字母的单词 - regex: find all words with certain letters but not other 正则表达式获取包含字母和(数字/某些特殊)的“单词”,但不仅仅是数字 - regex to get “words” containing letters and (numbers/certain special), but not only numbers 正则表达式查找以大写字母开头的单词,而不是在句子的开头 - Regex to find words starting with capital letters not at beginning of sentence 正则表达式查找包含字母和数字的单词的字符串 - regex to find a string contains words with both letters and digits 使用Python正则表达式查找以特定字母开头和结尾的单词 - Using Python regex find words starting and ending with specific letters python 中的正则表达式数字和字母 - Regex numbers and letters in python 通过使用正则表达式加上字典或python中的哈希映射来动态替换句子中单词的所有开头和结尾字母 - Dynamically replace all starting and ending letters of words in a sentence by using regex plus a dictionary or Hash map in python 在2个大写字母(regex)之前找到以大写字母开头的n个单词 - Find n words starting with capital letter before 2 words of capital letters (regex) 正则表达式Python用于数字/单词 - Regex Python For Numbers/Words
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM