There should be a strReplace() method in the String class, dontchya think?
I was just trying to strip xml tags off a node so I only end up with the text between the node tags.
ex.
xml doc
<xml>
<firstNode>some text here</firstNode>
</xml>
actionscript
var dtmp = my_xml.childNodes[0].firstChild.toString();
Now I understand that when this string (dtmp) is put on the stage the tags are stripped, but if it is traced the tags are obviously still there.
This wouldn’t really be an issue but I have to compare the value to another string so I had to come up with a way to have the text only.
I came up with this:
actionscript
dtmp = dtmp.substr(11);// 11 is the length of “<firstNode>” so now it’s stripped
var index = dtmp.indexOf("</firstNode>");
dtmp = dtmp.substr(0,index);
So now the result is what I needed.
I just think it would be, hrm, what’s the word… more comfortable using a strReplace() method.
I’ll probably work on making a strReplace() when I have some time.
Heheh, also regular expressions would be okay when dealing with imported xml, html, emails, etc.
Just my thoughts on this.