[R] [] and escaping in regular expressions
Ista Zahn
istazahn at gmail.com
Tue Sep 24 17:48:55 CEST 2013
On Tue, Sep 24, 2013 at 11:40 AM, Bert Gunter <gunter.berton at gene.com> wrote:
> Time to spend some time with the docs!
>
> ?egexp
Just to avoid any confusion: the documentation topic is ?regexp, not ?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.hannah at 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 at 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 at 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.
More information about the R-help
mailing list