1. Technology
Send to a Friend via Email

Regular Expressions

23. String Methods

clr gif

We have already looked at most of the string methods that can be used with regular expressions in the first few tutorials.

To make it easier for you to remember what they are and what they do here is a complete list.

  • match(re) works like the re.test() method to return an array of the parts of the string that match the regular expression.
  • replace(re,newstr) replaces each of the matches that are found with the replacement string specified (newstr).
  • search(re) works like the re.exec() method to test if a match is found.
  • split(re) splits the string up into an array containing each of the pieces of the string from between the matched sections. Effectively returns those pieces of the string not returned by match().

©2014 About.com. All rights reserved.