-2

With:

abc = 'abc'
xyz = 'xyz'

word = 'begin abc- middle_xyz_ end'

I need to extract the values of abc and xyz from word. The result should be

result = 'begin - middle__ end'

How to achieve this with a minimum amount of code?

alphanumeric
  • 15,954
  • 55
  • 201
  • 355

1 Answers1

4

You use replace() with an empty string as the value to replace with.

result = word.replace('abc','').replace('xyz','')