[REBOL] Re: Using parse to make intelligent substitutions.
From: chris:ross-gill at: 28-Apr-2003 13:05
Hi Mat,
> Bah only this doesn't work because it only does the first occurrence of
> "blog". OK I'm stuck :)
Just so happens I've been wading through parse rules a fair bit the last few
days, though that may also mean my solution is slightly overcooked.
- Chris
--
blog-ctx: context [
digits: charset "0123456789"
mark: foundblog: none
blog-rule: [
any [
to "blog" mark:
"blog" copy foundblog some digits
(
replace mark join "blog" foundblog rejoin [
mold build-tag compose [
A HREF (
join http://www.blah.com/blog.php?blog trim foundblog
)
] "blog " foundblog </A>
]
)
thru </A>
]
]
set 'replaceblogstr func [inputtext][
parse inputtext blog-rule
inputtext
]
]