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

[REBOL] Re: Help required for a little parsing problem

From: g:santilli:tiscalinet:it at: 19-Nov-2000 11:50

Hello Nigel! On 18-Nov-00, you wrote: NB> Whilst I could probably write a (long) solution I'm sure NB> there must be an elegant couple of line Rebol solution - one NB> problem is that there may be any number of links in the post. NB> Any suggestions? Just an idea: post-rule: [some [link | text]] link: ["[url]" copy url to "[/url]" 6 skip (emit-link url)] text: [copy chars [to "[url]" | skip to end] (emit chars)] emit-link: func [url] [ emit build-tag [A HREF (url) TARGET "_blank"] emit url emit </A> ] emit: func [text] [ insert tail output text ] output: "" parse-post: func [post] [ clear output if parse/all post post-rule [copy output] ]
>> print parse-post "This is a post - Perl is good [url][/url], Rebol is better [url][/url]"
This is a post - Perl is good <A HREF="" TARGET="_blank"></A>, Rebol is better <A HREF="" TARGET="_blank"></A> (Perhaps it's a bit long...) Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila --