Testing Regular Expression Match Pattern of Multiple Occurrences

Regular expression pattern match with multiple occurrences is a very powerful tool in text editing, software programming and software testing. It can used to parse desired values of multiple occurrences out of text files. This page allows you to learn and test regular expression pattern match multiple occurrences.

What is a regular expression?

A regular expression is a string of normal and meta characters that can be evaluated as a match pattern. The best reference guide on regular expression is the Perl manual called "perlre". You can easily find and download a copy of "perlre" on the Web. When a regular expression is appled for multiple occurrences, after the first match is found, the subsequent searches are continued on from end of the last match in the subject string. Multiple-occurrence matches are also called global matches.

For example, "/\b([A-Z0-9._%-]+)@([A-Z0-9.-]+\.[A-Z]{2,4})\b/i" is a regular expression that represents a pattern to match any email address. If apply this pattern to match all occurrences in a text file, you will get all the email addresses contained in the file.

How to test regular expression

To help you learn and test regular expression match patterns, FYIcenter.com has designed this online testing page using the PHP preg_match_all() funtion:

  • preg_match_all(pattern, subject, matches) - Returns the number of times the pattern matches in the subject.

All you need to do is to enter the pattern string and the subject string in the form below and click the Start button. Remember that the pattern string must include "/" as delimiters.



Popup Windows Tutorials

20 tutorials on different ways to create and test popup windows created in JavaScript: Page unload popups, Pop re-open on close, ...

200+ PHP Script Tutorials

Each tutorial answers one commonly asked PHP programming question with a short, but precise and clear PHP script.