jsEssentials
dateLib
jsStrings
Controls
Tools
Navigate
|
|
Description:
When replacing a number of different strings in a string, consecutive calls to String.replace() is not really efficient. This function solves this problem. It makes use of associative arrays.
This is my first attempt to make an UBB parser, which is used in web-forums.
Download:
code,
view-source.
Targetted: all
Tested on: win32: ie5..ie6, ns6.1 , OS X: ie5.1
Usage
s=listReplace(s,initTokenCache(aHTMLTokens));
var aTokenCache=initTokenCache(aUBBTokens);
s1=listReplace(s1,aTokenCache);
s2=listReplace(s2,aTokenCache);
//Use this form to replace just one string
s=listReplace(s,initTokenCache(aHTMLTokens));
//Or if more than one string needs to be taken care of
var aTokenCache=initTokenCache(aUBBTokens);
s1=listReplace(s1,aTokenCache);
s2=listReplace(s2,aTokenCache);
Live Demo
|