Several examples of regular expression in R.
Regular expression is a powerful tool to process strings. First example, we have strings 'q123er', 'a2334bc', 'b78gg'
and we want to let it be 'qer123qer', 'abc2334abc', 'bgg78bgg'
.
1 | a = c('q123er', 'a2334bc', 'b78gg') |
Second example is that we want add some string in front of the some characters. We want to search parenthesis in string, but parenthesis need escape or it cannot be found.
1 | b = c('p(478)cer', 'ba(2334)bdc', 'ber(728)gigi') |
Third example is that we take the information from strings.
1 | d = c('p478cer', 'ba2334bdc', 'ber728gigi') |