-
Replace "&" with "and"
Hi, i just did a ecard recently, and someone my php script will not allow this "&" character. How can i do a loop to check for a particular text field to replace whater "&" it found with "and" ?
thanks
-
dunno if that helps in your case, but you can transform special characters into escape sequences and then send that escaped string to php:
var myEscapedString = escape(_root.myTextBox.text);
-
Senior Member
In this case escaping the text seems reasonable, but if you did want to do a find and replace you might use something like this,
txt = txt.split("&").join("and");
which should replace all occurences of & in the variable txt with and.
-
hi guys!
thanks catbert303!
how would i go about converting multiple words?
for eg:
from: &, tree, day, sky
to: and, plant, night, ground
is there a quick way of doing this?
cheers!
FlashX
________________________
The mind lies, it only hears what it wants to hear.
-
Senior Member
Hi flashX,
You could try this:
var from = ["&", "tree", "day", "sky"];
var to = ["and", "plant", "night", "ground"];
for (var i = 0; i < from.length; ++i) {
txt = txt.split(from[i]).join(to[i]);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|