2

So if I have a string like:

plz_work = "text I want to get rid of HELLO want to keep this text HELLO want to keep this text"

I want to remove all the text before the first instance of HELLO, like the following:

"HELLO want to keep this text HELLO want to keep this text"

In this case, I used regex, and tried the following off of this and this:

 re.sub(r'.*HELLO','HELLO',plz_work,1)

But I get this:

'HELLO want to keep this text'

Why does this happen? I thought the last parameter signified count and means that it would only perform 1 substitution... why is it going wrong here? Any help would be greatly appreciated, thanks!!

ocean800
  • 3,489
  • 13
  • 41
  • 73

0 Answers0