[英]Find whole word for matching
I am trying to get the regex pattern to find whole word if it matches a word\\special character我试图让正则表达式模式找到整个单词,如果它匹配一个单词\\特殊字符
text = Details of Test-3K9Y9Y1-My-Node1 give me
I want to get Test-3K9Y9Y1-My-Node1
from the sentence.我想从句子中得到
Test-3K9Y9Y1-My-Node1
。
I tried:我试过:
>>> match = re.findall('(?<=-)\w+', text)
>>> match
['3K9Y9Y1', 'My', 'Node1']
text = 'Details of Test-3K9Y9Y1-My-Node1 give me'
s=text.split(' ')
for i in s:
if '-' in i:
print(i.split('-')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.