[R] stringr package question

Sarah Goslee sarah.goslee at gmail.com
Thu Aug 13 22:33:12 CEST 2015


Hi,

The + is a special character in regular expressions. If you want to
match a literal + you need to escape it:

str_extract("+proj=utm +zone=19 +datum=WGS84 +units=m +no_defs
+ellps=WGS84 +towgs84=0,0,0", "\\+proj=[a-zA-Z0-9]*")

Sarah


On Thu, Aug 13, 2015 at 2:55 PM, Mauricio Romero
<mauricioromerolondono at gmail.com> wrote:
> Hi,
>
> I'm running R 3.2.1 and im having an unexpected problem... when I run the
> follwing code it returns an error
>
> library(stringr)
> str_extract("+proj=utm +zone=19 +datum=WGS84 +units=m +no_defs +ellps=WGS84
> +towgs84=0,0,0", "+proj=[a-zA-Z0-9]*")
>
> But I can't find whats wrong with my code.
>
> Thanks
>
> Mauricio
>



More information about the R-help mailing list