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

[REBOL] Re: substring question

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/