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: christian:ensel:gmx at: 18-Nov-2000 21:59

Hallo Nigel, Andrew's version is even shorter than mine, doing it by just 'change -ing instead of 'remove -ing and 'insert -ing. Nevertheless, here's my version with additinal comments: parse post [ any ; apply the following rule 0 or more times [ to "[url]" ; jumps to the first occurence of "[url]" ; we're right ahead of it now tag: ; remember the position in the string 5 skip ; skip 5 characters ("[url]") copy url to "[/url]" ; copy everthing till we encounter a ; string "[/url]" ; 'url now holds the url, but not the brackets ; all the above is the 'parse dialect ( ; start of code (non-dialect) section remove/part tag add length? url 11 ; remove length? url plus additional 11 ; chars ("[url]" = 5 + "[/url]" = 6) ; from the input string, ; counting from the position we told ; 'parse to remember in 'tag insert tag rejoin [ {<a href="} url {" target="_blank">} url {</a>} ] ; composes the html-tag and inserts ; it at the position 'tag ; voila! ) ; end of code section ] to end ] If you want to learn about 'parse see the new user guide on rebol.com, chapter 14. Have fun! Christian [Christian--Ensel--GMX--De]