0

I have text which contains code.

It is possible to recognize because code exist into an html tag like this

<code> print(i)
</code> 

I know it is possible to remove html tags in R?

However how is it possible to remove the content into a specific tag like my case?

The code I mention exists in text. A better example:

You can find an incredible solution if you use <code> print(i) </code> and you will solve your problem.

and I want to remove the specific tag and what it is inside the tag and have only:

 You can find an incredible solution if you use and you will solve your problem
Dave2e
  • 22,192
  • 18
  • 42
  • 50
user8831872
  • 383
  • 1
  • 14
  • 1
    Something like this?: `gsub(".+?", "", text)` – Dave2e Mar 05 '18 at 21:40
  • Obligatory link: https://stackoverflow.com/a/1732454/474349 – Hong Ooi Mar 05 '18 at 23:51
  • @HongOoi, people need to stop linking that answer when the questions are not about parsing a whole webpage with regex (which is probably possible anyway due to the fact that most regex engines aren't as regular as the name suggests) - it'd just be more efficient to use a document parser for it. – KyleFairns Mar 06 '18 at 09:41
  • @KyleFairns No. We need to keep linking that answer. Otherwise people will think, oh, that was easy, and go from "how do I remove a tag" to "how do I remove table tags" to "how do I handle css descriptors" and before you know it, Zalgo has come. – Hong Ooi Mar 06 '18 at 10:05
  • @HongOoi, when the ones that can't easily be done with regex come up, thats when the answer should be linked. – KyleFairns Mar 06 '18 at 10:54
  • @KyleFairns think of it as pre-empting those kinds of questions – Hong Ooi Mar 06 '18 at 10:55
  • @HongOoi But it is irrelevant to the questions that you are linking it on, therefore, you shouldn't link it. – KyleFairns Mar 06 '18 at 10:56
  • @KyleFairns think of it as an educational opportunity. – Hong Ooi Mar 06 '18 at 10:57

0 Answers0