I have the following text:
'The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was unaffected by these events.'
I'm trying to replace each word with user input. I am using regular expressions to match the words and get them to a list.
I am using re.sub
to replace the userinput
with the matched regex group. But is there a way I can only replace the first matched group, or second or third?
NOUN
comes up twice, so in my for
loop, I want the user input to only replace regex.group[0]
or [1]
, for example.