[REBOL] Re: REBOL embedded $variables regexp/no
From: lmecir:mbox:vol:cz at: 10-Dec-2002 18:23
Hi Gabriele,
----- Original Message -----
From: "Gabriele Santilli" <[g--santilli--tiscalinet--it]>
To: "Ladislav Mecir" <[rebol-list--rebol--com]>
Sent: Tuesday, December 10, 2002 3:16 PM
Subject: [REBOL] Re: REBOL embedded $variables regexp/no
> Yes, I've done exactly that in my NOT-RULE defined in that email.
> However, I think this is too inefficient, and in most cases you
> can very easily provide a rule for the non-matching part of the
> text which is much more efficient.
If you want efficiency, then this looks more efficient without needing any
additional rule:
pattern-replace: function [
string [string!]
match-pattern [block! string!]
replacement [string!]
] [result start end] [
result: make string! length? string
parse/all string [
start:
any [
end: match-pattern (
insert insert/part tail result start end replacement
) start: | skip
]
(insert tail result start)
]
result
]
What do you think?
-L