Results 1 to 2 of 2

Thread: replace function and "("

  1. #1
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default replace function and "("

    I am having some trouble with the replace() function in JS.
    I need to replace all of these: (center]
    with these: <center>
    and these: [center)
    with these </center>
    etc.
    I can change one, but I need to change them all in a string that the user types in (it's for a forum, obviously).

    Thx.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  2. #2
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Code:
    myStr.replace(/\(center\]/g, "<center>").replace(/\[center\)/g, "</center>");
    For case insensitivity as well:
    Code:
    myStr.replace(/\(center\]/gi, "<center>").replace(/\[center\)/gi, "</center>");

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •