如何使用RegEx将一个单词模式重复两次(可能中间有空格)?

2024-10-03 09:21:10 发布

您现在位置:Python中文网/ 问答频道 /正文

如何连续重复同一个单词两次或更多次,中间可能有不同的空格

这就是我所尝试的:

e = "bored         bored boredbored"
if re.search(r"{}\s*s/", e):
    print("The sequence " + e + " contains the same word written two or more times in a row with possible varying intervening whitespace.")

Tags: theresearchif单词wordsame空格