[R] Regexpr with "."

Chuck Cleland ccleland at optonline.net
Wed Aug 13 17:10:22 CEST 2003


Thompson, Trevor wrote:
> I'm trying to use the regexpr function to locate the decimal in a character
> string.  Regardless of the position of the decimal, the function returns 1.
> For example,
> 
>>regexpr(".", "Female.Alabama")

   You probably want backslashes to indicate that "." should not 
be treated as a metacharacter; it should be taken literally.

 > regexpr("\\.", "Female.Alabama")
[1] 7
attr(,"match.length")
[1] 1

hope this helps,

Chuck Cleland




More information about the R-help mailing list