Results 1 to 2 of 2

Thread: replace function???

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Hellmer/Quebec/Canada
    Posts
    32
    I want to know if there is a function in Javascript that can replace charater by another one.....ex:

    var htmlcontent;
    htmlcontent ="hello world";

    htmlcontent= replace(htmlcontent,o,i);

    alert(htmlcontent);




    and I want the alert to show "helli wirld". Is there a function that can do that???
    Forza Scuderia Ferrari

  2. #2
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367

    Regular expressions

    Yeah, if you use regular expressions this will be easy.

    var myString = "Hello World";
    var results = myString.replace(/o/gi,"i");
    alert(results);

    regexpr is /texttolookfor/g is for globlal, i is for ignore case
    Last edited by billrogers; Mar 21st, 2001 at 03:26 PM.

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