import re
input_text_to_checkA = "to play football in the street you need good boots" #For example
regex_patron_00A = r"\s*\¿?(?:so you can play |so you can play |to play the |to play )\s*((?:\w+\s*)+)\s*\??"
regex_patron_00B = r" \s*((?:\w+\s*)+) \s*\¿?(?:are really necessary the |are really necessary |would be needed from |would be needed |she needs |he needs |you need )\s*((?:\w+\s*)+)\s*\??"
mA = re.search(regex_patron_00A, input_text_to_checkA, re.IGNORECASE)
if mA:
input_text_to_checkB = mA.group() # ---> "football in the street you need good boots"
mB = re.search(regex_patron_00B, input_text_to_checkB, re.IGNORECASE)
if mB:
word, association = m.groups()
word = word.strip() # ---> "football in the street"
association = association.strip() # ---> "good boots"
I need input_text_to_checkB = "" to store the string without the beginning of what was valid in the first regex and without what was stored in the word variable.