[R] extracting text contained in brackets ("[ ... ]") from a character string?

From: new ruser <newruser_at_yahoo.com>
Date: Sun, 13 May 2007 13:26:55 -0700 (PDT)


I have a text string that contains text within two brackets.

e.g. "testdata[3]" "testdata[-4]", "testdata[-4g]",

I wish to "extract" the string enclosed in brackets?

What is a good way to do this?

e.g.

fun(testdata[3]) = '3'

fun(testdata[-4g]) = '-4g'        



Moody friends. Drama queens. Your life? Nope! - their life, your story.

        [[alternative HTML version deleted]]



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 13 May 2007 - 20:31:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 May 2007 - 00:31:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.