I need extract double Male-Cat:
a = \"Male-Cat Male-Cat Male-Cat-Female\"
b = re.findall(r\'(?:\\s|^)Male-Cat(?:\\s|$)\', a)
print (b)
[\'Male-C
Use lookarounds to extract words inside whitespace boundaries:
r'(?<!\S)Male-Cat(?!\S)'
See the online regex demo
Details
(?<!\S) - a whitespace or start of string must appear immediately to the left of the current locationMale-Cat - the term to search for(?!\S) - a whitespace or end of string must appear immediately to the right of the current locationSince (?<!\S) and (?!\S) are zero-width assertions, the whitespace won't be consumed, and consecutive matches will get found.