Entfernen Sie den gesamten Text zwischen zwei Klammern
Angenommen, ich habe einen Text wie diesen,
text<-c("[McCain]: We need tax policies that respect the wage earners and job creators. [Obama]: It's harder to save. It's harder to retire. [McCain]: The biggest problem with American healthcare system is that it costs too much. [Obama]: We will have a healthcare system, not a disease-care system. We have the chance to solve problems that we've been talking about... [Text on screen]: Senators McCain and Obama are talking about your healthcare and financial security. We need more than talk. [Obama]: ...year after year after year after year. [Announcer]: Call and make sure their talk turns into real solutions. AARP is responsible for the content of this advertising.")
und ich möchte den gesamten Text zwischen [und] (und den Klammern selbst) entfernen (bearbeiten: loswerden). Wie geht das am besten? Hier ist mein schwacher Versuch, Regex und das stingr-Paket zu verwenden:
str_extract(text, "\\[[a-z]*\\]")
Danke für jede Hilfe!