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

[REBOL] Re: Using parse to make intelligent substitutions.

From: mat:plothatching at: 28-Apr-2003 19:32

Hello Christopher, Thanks for your reply! CRG> Just so happens I've been wading through parse rules a fair bit the last few CRG> days, though that may also mean my solution is slightly overcooked. That's quite interesting, it's definitely what I was looking for the way you've got mark: in there and searching and replacing on that. I found out why my last one didn't work past the first one, obvious really. The subrule needs to return positive for the any to continue. So the solution was to change some digits to any digits. This required the addition of a conditional on the temporary variable to check to see if there's anything in 'foundblog'. Here's my production code; replaceblogstr: func [ inputtext /local digits blogsfound foundblog ][ digits: charset "0123456789" blogsfound: copy [] parse inputtext [any [thru "blog " copy foundblog any digits ( if foundblog [append blogsfound to-integer foundblog] ) ] ] foreach foundblog blogsfound [ replace InputText rejoin["blog "foundblog] rejoin[{<A HREF="}foundblog{.txt">blog }foundblog{</A>}] ] InputText ] This works and isn't so kludgy that I insist on rewriting it just on principal. Thanks for your example, that technique is going to help when I do other things like this in the future. Certainly it's going to let me write complex parsing stuff faster and smaller in the future. I've *really* jumped through some hoops just to get things to work in the past. I guess I should probably use build-tag as well but I've been doing it with strings by hand for so long now it'll be a hard habit to kick. :) P.S. Has anyone written a function to get results from Google's SOAP interface? I've got loads of stuff based on parsing HTML but I'd like to switch to the SOAP interface as it's obviously more efficient. Regards, Mat Bettinson - +44-(0)20-83401514.