OZONE Asylum
Forums
DHTML/Javascript
Message Format
This page's ID:
28675
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Why not using a RegExp ? this way you can use the {index} several times.[code]StringFormatter.prototype.format = function( str ) { var i=0; while( ++i<arguments.length ) str = str.replace( new RegExp( '{'+(i-1)+'}', 'g' ), arguments[i] ); return str; }[/code]Also the usage seems to be:[code]var s = "His name is {0}.\n\rHe likes {1}.\n\r{2} also like {1}."; alert( MessageFormat.format(s,"Yossi","JavaScript","p01"));[/code];) [url=http://www.p01.org/][img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_galaxy.gif[/img][/url] [small](Edited by [url=http://www.ozoneasylum.com/user/2185]poi[/url] on 11-28-2006 09:16)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »