R remove non-alphanumeric symbols from a string

rregex

I have a string and I want to remove all non-alphanumeric symbols from and then put into a vector. So this:

"This is a string.  In addition, this is a string!" 

would become:

>stringVector1

"This","is","a","string","In","addition","this","is","a","string"

I've looked at grep() but can't find an example that matches. Any suggestions?

Best Solution

here is an example:

> str <- "This is a string. In addition, this is a string!"
> str
[1] "This is a string. In addition, this is a string!"
> strsplit(gsub("[^[:alnum:] ]", "", str), " +")[[1]]
 [1] "This"     "is"       "a"        "string"   "In"       "addition" "this"     "is"       "a"       
[10] "string"