Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私が持っているとします:
string = "2 dogs. 4 cats. 9 horses. 7 goats"
数字の前にあるすべての単語に一致させたい。
私は試した:
matches = re.search(r"(?<=\d+) \w+", string)
しかし、それは機能していません。
>>> s = "2 dogs. 4 cats. horses. 7 goats" >>> import re >>> re.findall(r'\d+\s(\w+)', s) ['dogs', 'cats', 'goats']