Regular Expression Tutorial 2: Commands in R


The second part of the tutorial for regular expression will cover common commands used in R together with regular expression. Once you know how to write a regular expression to match a string, you may want to manipulate strings such as deletion or replacing. Here is the list of string matching &manipulation commands commonly used with regular expressions in R. These commands also appear in many other languages.

Command          Function grep( )          Return index of the object where reg exp found the string grepl( ) Return logical values for reg exp matching regexpr( ) Return the first position of found string by reg exp gregexpr( ) Return all positions of found string by regexp sub( ) Substitute a pattern with a given string (first occurrence only) gsub( ) Globally substitute a pattern with a given string (all occurrences) substr( ) Return the substring in the giving character positions (start and…

View original post 806 more words


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s