PHP Classes

File: tests/replace.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Marco Marchiņ  >  Regexp Builder  >  tests/replace.php  >  Download  
File: tests/replace.php
Role: Example script
Content type: text/plain
Description: Replace example
Class: Regexp Builder
Build regular expressions programmatically
Author: By
Last change:
Date: 5 years ago
Size: 530 bytes


Class file image Download
require_once "../regexpBuilder.php";
Replace function test. Replace every space with the space character in html format (&nbsp;).
Format: This is a test
- find space charachter repeated one or more times
- replace with &nbsp;

$regexp=new regexpBuilder();
$regexp->match(SPACE_CHAR)->oneOrMoreTimes(); //find space charachter repeated one or more times

$result=$regexp->replaceWith("&nbsp;","This is a test");
"This is a test<br>Result: ".$result; //Result: This&nbsp;is&nbsp;a&nbsp;test