Time to spend some time with the docs!

?egexp

tells you:

". (Only ^ - \ ] are special inside character classes.)"

See also inline below.

Cheers,
Bert


On Tue, Sep 24, 2013 at 8:30 AM, Juliet Hannah <juliet.han...@gmail.com>wrote:

> Is it correct that one does not need to escape special characters such as
> "*" (are these
> properly called metacharacters) inside []. If so, what is the logic to
> this?
>

Huh?  Are you aware that regular expressions are actually a context free
grammar IIRC (computer science gurus, please confirm or correct)?

>
> mytest <- "he*llo"
> sub("[*]","",mytest)
> sub("\\*","",mytest)
>
> [] is easier to read for me than \\. Is this what people tend to use?
>

That would require a survey to answer, would it not? Tastes vary, as they
say.



> Thanks.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to