> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Hadley Wickham
> Sent: Friday, November 13, 2009 5:34 AM
> To: r-help
> Subject: [R] Escaping regular expressions
>
> Hi all,
>
> Is there a met
This is not minimal (it will escape every non-word character) but is
short and the needlessly escaped ones should do no harm (though you
might want to double check that assumption on a few examples):
gsub("(\\W)", "\\1", x)
On Fri, Nov 13, 2009 at 8:33 AM, Hadley Wickham wrote:
> Hi all,
>
>
I want the user supplied string to be used as a component of a regular
expression that I build up from other pieces that need actual regular
expressions.
Hadley
On Fri, Nov 13, 2009 at 7:41 AM, Henrique Dallazuanna wrote:
> Try the fixed argument:
>
> grep(".$^", c("Test.$^", "Test"), fixed = TR
Try the fixed argument:
grep(".$^", c("Test.$^", "Test"), fixed = TRUE)
On Fri, Nov 13, 2009 at 11:33 AM, Hadley Wickham wrote:
> Hi all,
>
> Is there a method for escaping strings to be used regular expressions?
> i.e. if I have a user supplied string that I'd like to use as a fixed
> componen
Hi all,
Is there a method for escaping strings to be used regular expressions?
i.e. if I have a user supplied string that I'd like to use as a fixed
component is there a method that will turn (e.g.) ".$^" into
"\\.\\$\\^" ?
Thanks,
Hadley
--
http://had.co.nz/
5 matches
Mail list logo