F
F
femto2020-09-04 21:31:39
Python
femto, 2020-09-04 21:31:39

How to remove a word from a string?

There is a code:
name = 'Vasya vasya VASYA'
you need to cut out all 'vasya' from name,
the variable is not static, so as I understand it, regular expressions are needed,
help me compose.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2020-09-04
@femto

re.sub(r"vasya", "", "Vasya foo vasya bar VASYA", 0, re.IGNORECASE)
https://ideone.com/cHZ8gO

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question