[R] How to create a string containing '\/' to be used with SED?

seanpor seanpor at acm.org
Thu Nov 27 06:42:14 CET 2008


What is the problem error message?  I can say

> fred <- "blah1\\/blah2\\/blah3"

and then the string looks like...

> cat("#", fred, '#\n', sep='')
#blah1\/blah2\/blah3#

If you just ask R to print it then it looks like...
> fred
[1] "blah1\\/blah2\\/blah3"
>

when you're "playing" with strings and regular expressions, it's vital to
understand the backslash quoting mechanism...

Best regards,
Sean


ikarus wrote:
> 
> I still can't create a string with inside "\/"  (e.g., a <-
> "..\\/path\\/file"
> doesn't work, R complains and the \\ are removed), ... <snip>
> 
-- 
View this message in context: http://www.nabble.com/How-to-create-a-string-containing-%27%5C-%27-to-be-used-with-SED--tp20694319p20713699.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list