Regular expressions from arrays

Discussion in 'JavaScript' started by Samji, Apr 30, 2007.

  1. #1
    Hello.

    Is it possible to create regular expressions from text in arrays. For example, I have this code - http://html-channel.com/pastebin.php?id=6

    I noticed that I can do this with the replace method on dmessage.

    
    alert(dmessage.replace(/b/, "B"));
    
    Code (markup):
    Replace lowercase 'b' with 'B and display the document contents in an alert window. How could I go about:

    a) Using array indexes with the replace method on the document (BTW its XML)
    b) Updating the document with the changes made, rather than just displaying in alert.

    Thanks in advance.
     
    Samji, Apr 30, 2007 IP