Short: New efun map_replace() From: "Dale Perkins" <dale-perkins@home.com> Date: Sun, 4 Jul 1999 03:33:13 -0500 Type: Feature State: Unclassified HI, I was wondering, could you implement an efun that would take a string and a mapping as an arg and replace all occurrences of the keys of the mapping in the string with the value of the key? something like map_replace("a b c d", ([ "a" : "a", "c" : "2"])) would return "1 b 2 d" This is very similar to what terminal_colour does but without the delimiters. Note: Internally this would probably be best solved with by creating a pattern (key1)|(key2)|...), and looping calls to regexp() over the string, analyzing the internal state of regexp() whenever it finds something. Lynx writes: ich brauche sowas dauernd, und habe es bisher mit einer lausigen schleife um einem sscanf herum. der zweck ist "html templates", also html fragmente die unterschiedlich eingesetzt werden. was ich dabei ersetze ist typischer- weise die aktuelle baseurl von bildern (weil ich bisher kein 8-bit sauberes read_file habe.. ist das in ldmud eigentlich gefixt?) und so sachen wie url des aktuellen objektes oder aktueller query string usw. usf. :) also irgendwie kann man sowas dauernd gebrauchen.. aber bei mir wäre ein mapping womöglich gar nicht flexibel genug, manchmal muss ich die replacements dynamisch erst auftreiben.. mach mir nur sorgen ob lpc dann noch schnell genug ist.. egal, das alles sage ich nur so FYI, als beispiel einer anwendung von map_replace or whatever.. frohes schaffen!