Testing Regular Expression Match and Replace

Regular expressions are commonly used in pattern matches and replacements processes. Many text editors, programming languages, and software testing tools offers pattern match and replacement functions. This page allows you to learn and test regular expression used in match and replacement processes.

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.

For example, "/^(http:\/\/)?[^\/]+/i" is a regular expression that represents a pattern to match the base URL of any Web page URL.

How to use regular expressions in a search and replace function?

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

  • preg_replace(pattern, replacement, subject) - Returns the subject with matched patterns replaced.

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.