Previous Example-|-Next Example-|-Return to Chapter Listing

Example 14.14:
More Regular Expression Examples

[This example works with Netscape Navigator 4. It won't work with Netscape Navigator 2 or 3, or Internet Explorer 3.]

Type some text into the form--anything you want. Then enter a word you want to search for and click the button. The last text box will display either -1 (meaning it didn't find what you're looking for) or the number of characters in the text you specified.

The match() method

Enter some text:

Enter a pattern (without "/" characters):     Modifiers (i, g, or both):

    Results (the number of characters found):

Result length:

Outputs:

Memorized values:


The replace() method

Enter some text:

Input a pattern (without "/" characters):     Modifiers (i, g, or both):

What do you want to replace the matched text with?

    Results:

Result length:

Outputs:

Memorized values:


The split() method

Input some text:

Input a pattern (without "/" characters):

    Results:

Result length:

Outputs:

Memorized values:


Phone number extractor using match()


Phone number extractor using split()



Previous Example-|-Next Example-|-Return to Chapter Listing