Regular expressions
, taken to their extreme, can make you feel irregular. For many R programming tasks, only a few meta-characters need be used. Table
6-1 is from an excellent Loyola Marymount University website.
1 In R, the regular expression will be enclosed in quotes and used in one of the seven functions listed in Chapter
9, “The Magnificent Seven.”
Table 6-1Example regular expressions
Example regular expression | Matches any string that |
|---|
Hello | Contains {hello}. |
gray|grey | Contains {gray, grey}. |
gr(a|e)y | Contains {gray, grey}. |
gr[ae]y |