Re: [R] "Special" characters in URI

From: Gregor GORJANC <gregor.gorjanc_at_bfro.uni-lj.si>
Date: Tue 03 May 2005 - 23:48:52 EST

Henrik Bengtsson wrote:
...

>> Henrik, thanks. So you suggest something like
>>
>> for (i in seq(along=map)) {
>>     URL <- gsub(pattern=names(map)[i], replacement=map[i], x=URL)
>> }
>>

>
> Yes, something like that. To optimize, you might want to do
>
> patterns <- names(map);
> for (i in seq(along=map)) {
> URL <- gsub(pattern=patterns[i], replacement=map[i], x=URL)
> }
>
Do I gain anything more than readability by this optimization?

> More important is that you treat a standard "%" different from a "%"
> used in encoding, e.g. how do you want to convert the string "100% %20"?
> You probably have to utilize more "fancy" regular expressions to detect
> a standard "%". Maybe "%[^0-9a-fA-F]" will do. There should be much more
> details in the document Brian Ripley refered you to.
>
> In other words, you have to be careful and try to think through all
> cases you function may be called. A good test is to call it twice, once
> on your original string and the on the escaped on; you should get the
> same result. It depends how complete you want your function to be.
Thanks again.

-- 
Lep pozdrav / With regards,
    Gregor Gorjanc

----------------------------------------------------------------------
University of Ljubljana
Biotechnical Faculty        URI: http://www.bfro.uni-lj.si/MR/ggorjan
Zootechnical Department     mail: gregor.gorjanc <at> bfro.uni-lj.si
Groblje 3                   tel: +386 (0)1 72 17 861
SI-1230 Domzale             fax: +386 (0)1 72 17 888
Slovenia, Europe
----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try." Sophocles ~ 450 B.C.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed May 04 00:29:16 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:32 EST