www.webdeveloper.com
Results 1 to 2 of 2

Thread: replace()

  1. #1
    Join Date
    Feb 2008
    Posts
    9

    replace()

    Can't seem to get this to work. Simply trying to replace some text in a string. Any ideas?

    var ans = "<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mrow><mtext id='carat'>|</mtext></mrow></math>";

    ans.replace("<mtext id='carat'>|</mtext>", "<mfrac><mrow><mtext id='carat'>|</mtext></mrow><mrow><mn>3</mn></mrow></mfrac>");


    Thanks!

  2. #2
    Join Date
    Mar 2009
    Posts
    511
    The replace method doesn't alter the original string. It returns a new string with the requested changes.

    Do:

    ans = ans.replace(...your stuff)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles