Home>

For example, I want to replace all sentences before the word "despite" with spaces.

"Usually, a professor who is knowledgeable is definitely advantageous in comparing knowledge, but an assistant devises ~"
If there is a sentence
I want to say, "The assistant devises ~".

I tried it below, but it didn't work.

solved.

sentense = "Usually, the assistant devises, even though the professor who is knowledgeable is definitely advantageous in comparing knowledge."
re.sub (r ". * (despite)", "", sentense)
  • Answer # 1

    How about using the split method of str?

    s = sentence.split ("despite") [1]
    print (s) #, the assistant devised,

  • Answer # 2

    sentense = "Usually, the assistant devises, even though the professor who is knowledgeable is definitely advantageous in comparing knowledge."
    re.sub (r ". * (despite)", "", sentense)