to complicate rape

import re
a = """cloudy

BB - continually 53, continual 26, daily 7, always 6, alway 4, ever 3,
perpetual 2, continual employment 1, evermore 1, never 1; 104

1 cloudy"""

b = """sunny

BB - Akkub 8; 8

extra strings here

1 sunny"""

c = """rainy

BB - Hezekiah 85, Hizkiah 1, Hizkijah 1; 87

extra strings here

1 rainy"""

r = re.compile(r'(?s)(?=BB)(.+)(?<=\d(?=.?\n))')

for i in (a, b, c):
    s = r.search(i).group()
    print(s)

Output:

BB - continually 53, continual 26, daily 7, always 6, alway 4, ever 3,
perpetual 2, continual employment 1, evermore 1, never 1; 104
BB - Akkub 8; 8
BB - Hezekiah 85, Hizkiah 1, Hizkijah 1; 87

Edit: added an extra \n.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top