Remove all text between two brackets

With this:

gsub("\\[[^\\]]*\\]", "", subject, perl=TRUE);

What the regex means:

  \[                       # '['
  [^\]]*                   # any character except: '\]' (0 or more
                           # times (matching the most amount possible))
  \]                       # ']'

Leave a Comment