tags:

views:

47

answers:

3
>> to-string pick [abc/def] 1
== "abcdef"
>>

How can I get "abc/def" instead ?

+1  A: 

Using string, which is delimited by {}, you can then use the ^(xx) format to insert an ASCII character by hex code.

Example:

>> to-string pick [{abc^(2F)def}] 1
== "abc/def""
>>

Use the ASCII table here if you need more codes.
For more information on REBOL strings see this link.

Stuart Thompson
That works, thanks for the link, never thought about reading it before, now I will.
Rebol Tutorial
+2  A: 
mold pick [abc/def] 1
 == "abc/def"

Or:

form pick [abc/def] 1
=="abc/def"
Sunanda
That's quite elegant syntaxes, thank you.
Rebol Tutorial
+1  A: 

The to- family of functions were changed in Rebol 3, and your code now provides the string you want. OTOH, form works in 2 and 3.

Are you using pick [abc/def] 1 because you wanted the literal path abc/def (and not have the interpreter try to pick def out of abc)? You can use quote to get that effect more simply:

>> form quote abc/def
== "abc/def"

And then there's the shorthand:

>> form 'abc/def
== "abc/def"
Hostile Fork
Hi thanks, will try Rebol 3 soon.
Rebol Tutorial