roxen.lists.pike.general

Subject Author Date
replace() with hit information Stephen R. van den Berg <srb[at]cuci[dot]nl> 13-02-2009
Would replace(string, array(string), array(string), mapping(string:int))
be a useful/convenient interface for the following functionality?:

I'd like the 4th argument mapping to be filled by the replace function
to tally the number of times it has found and replaced the corresponding
string.

It is difficult at best to obtain that information (efficiently) otherwise,
especially when some of the strings fit in the prefix of some of the others.

The actual use case for me is the bindings parser for pgsql, which preferably
needs to eliminate any unused variables before constructing the query to
be sent to the database.
The reason I'm looking at this is because I just had an occurrence of
a binding called ":telno" and ":telnopriv", whereas the :telno wasn't present,
but the :telnopriv was.  Quick checks with has_value() break down in this
case, because :telno is found as a prefix of the actually occurring :telnopriv,
obviously.

Any alternate ideas which solve this problem are welcome, of course.
-- 
Sincerely,
           Stephen R. van den Berg.
"Having a non-smoking section in a restaurant is like
 having a non-peeing section in a pool."