T
T
tadej2016-02-06 19:53:30
Python
tadej, 2016-02-06 19:53:30

How to remove empty tags in text using regular expressions?

Good day.
There is a task to clean up the text from unnecessary empty type tags <a></a>, <div class="block"></div>in the Python language.
How to create a regular expression correctly?
What is the best library to use for cleaning?
If possible a test working example.
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Deodatuss, 2016-02-06
@tadej

tyts

S
Sly_tom_cat ., 2016-02-07
@Sly_tom_cat

They gave a regular, so you need to put it in re.sub with an empty value of what to change to.
type
re.sub(regexp, '', source)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question