• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Replacing Text

Besides searching for matches to regular expressions, you also can use them to replace text, using the String object’s replace method:

  • The String object’s replace method. This method replaces substrings with a new string. Syntax: string.replace(regExp, replacementText); where regExp is a regular expression, and replacementText replaces matches to regExp. (All matches are replaced if regExp includes the g modifier.) See Chapter 18 for more information.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint