我希望在我处理的所有字符串中都能找到一种模式。
regex = re.compile(r'<pc.*>')
string = "<pc this is the 1st occurrence> words are displayed here <pc this is the second occurrence>"
re.findall(regex,string)
所需的输出:
['<pc this is first occurrence>', '<pc this is the second occurrence>']
实际输出:
["<pc this is the 1st occurrence> words are displayed here <pc this is the second occurrence>"]
如何重新构造正则表达式以获得所需的输出