A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Replace "&" with "and"

  1. #1

    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

  2. #2
    Member Pepember
    Join Date
    Jul 2001
    Location
    Berlin
    Posts
    886
    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);
    Please sign here

  3. #3
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    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.

  4. #4
    Senior Member
    Join Date
    May 2002
    Posts
    359
    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.

  5. #5
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center