Trevor, The "." is a regex meta-character that matches any character. In order to look specifically for a ".", the you must escape it with a "\", and that "\" must also be escaped, thus,
> regexpr("\\.", "Female.Alabama") [1] 7 attr(,"match.length") [1] 1 > HTH steve "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") > [1] 1 > attr(,"match.length") > [1] 1 > > In trying to figure out what was going on here, I tried the below command: > > > gsub(".", ",", "Female.Alabama") > [1] ",,,,,,,,,,,,,," > > It looks like R is treating every character in the string as if it were > decimal. I didn't see anything in the help file about "." being some kind > of special character. Any idea why R is treating a decimal this way in > these functions? Any suggestions how to get around this? > > Thanks for any suggestions. > > -Trevor > > > [[alternative HTML version deleted]] > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help