Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

substring question

 [1/5] from: al:bri:xtra at: 19-Jan-2001 16:27


Jeff Patton wrote:
> Basically, given a string like: > "/C/Rebol/files/" > > I'd like to do something to get a string back like: "/C/Rebol/" >> f: %"/C/Rebol/files/"
== %/C/Rebol/files/
>> clean-path f/..
== %/C/Rebol/
> I'm trying to extract a substring from a string and I'm crippled by my
knowledge of other language functions like lastIndexOf, firstIndexOf and substring.
>> s: "ABCDEFG"
== "ABCDEFG"
>> first s
== #"A"
>> last s
== #"G"
>> copy/part at s 4 3
== "DEF"
>> s: "/C/Rebol/files/"
== "/C/Rebol/files/"
>> parse/all s "/"
== ["" "C" "Rebol" "files"]
>> p: 'c/Rebol/files
== c/Rebol/files
>> p/2
== Rebol
>> p/3
== files I hope that helps! Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [2/5] from: al:bri:xtra at: 19-Jan-2001 16:45


Jeff Patton wrote:
> Having trouble trying to adapt rebol's find, copy and remove to do what I
want.
>> s: "Rebol is a bad language to learn."
== "Rebol is a bad language to learn."
>> replace s "bad" "good"
== "Rebol is a good language to learn."
>> append s " and use."
== "Rebol is a good language to learn. and use."
>> remove find s "."
== " and use."
>> s
== "Rebol is a good language to learn and use." I hope that helps! Andrew Martin Just writing Rebol... ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [3/5] from: jeff-patton:home at: 18-Jan-2001 19:49


Thanks Andrew - it was actually clean-path I needed all along. -Jeff

 [4/5] from: rphilipp:suffolk:lib:ny:us at: 18-Jan-2001 23:54


Andrew, I don't know about Jeff, your examples help me a lot. Robert P.

 [5/5] from: jeff-patton::home::com at: 18-Jan-2001 19:05


Feel like I should be able to answer this myself, but I'm having no luck. I'm trying to extract a substring from a string and I'm crippled by my knowledge of other language functions like lastIndexOf, firstIndexOf and substring. Having trouble trying to adapt rebol's find, copy and remove to do what I want. Basically, given a string like: /C/Rebol/files/ I'd like to do something to get a string back like: "/C/Rebol/" thanks in advance, -Jeff