String.prototype.Replace = function(what, bywhat) {
while (this.indexOf(what)>-1) {
var tmp = this.split(what);
this = tmp.join(bywhat);
}
return (this);
};
I would recommend you this way because if there is ever a duplication
after one cycle you may get bad results with the previous method.
Just a while() added.
msg11 {
omeomi[+],
posted: 04.22.04 9a•-,
top [^]
}
Wow, have you folks ever heard of reserved words? Using variables named things like "string" or "start" is generally a bad idea. Also, the counter var below needs to be initialized to 0 for that while condition to make sense...maybe it worked in an old version of Flash, but it doesn't work now. Here's the above code fixed...it works okay now in Flash MX 2004:
msg12 {
mother[+],
posted: 06.08.06 2p•06.08.06 2p,
top [^]
}
Here's a recursive method if you're into that...I've just grown not to trust 'while' statements in actionscript and found this to work just as well (for smaller strings at least). If you're going to be using this for larger strings I would recomend adding in a 'counter' for the '.indexOf' and pass it along with the recursion.
msg13 {
dvmorris[+],
posted: 08.24.06 4a•-,
top [^]
}
would there be a way to get this kind of function to work in the context of an l-system equation, where you define simple rules for string replacement, and perform them simultaneously?
It seems at first glance that the functions on this page wouldn't suffice to get results like the ones on the page above, but i'm not quite sure. I don't know much about l-systems, I'm just trying to get started understanding them, and there is little info on the web about specific algorithms.
Thanks for your help,
msg14 {
MadeBySquad[+],
posted: 10.19.06 1p•10.19.06 1p,
top [^]
}