[R] Regex for ^ (the caret symbol)?

Rich Shepard rshepard at appl-ecosys.com
Mon Jan 21 16:35:18 CET 2013


On Mon, 21 Jan 2013, mtb954 at gmail.com wrote:

> I am trying to search for string that includes the caret symbol, using the
> following code:
> grepl("latitude^2",temp)

   Many regex implementations require us to escape a metacharacter such as
'^' by preceeding it with a backslash. This indicates the next character is
a literal and not, in this case, the beginning of the line. Try \^ in your
statement.

Rich



More information about the R-help mailing list