PHP Classes

File: tests/grep.php

Recommend this page to a friend!
  Classes of Marco Marchiņ   Regexp Builder   tests/grep.php   Download  
File: tests/grep.php
Role: Example script
Content type: text/plain
Description: Grep example
Class: Regexp Builder
Build regular expressions programmatically
Author: By
Last change:
Date: 13 years ago
Size: 671 bytes


Class file image Download
require_once "../regexpBuilder.php";
Get every string that contains only letters:
Format: array("abc"," ",".","def","");

- match line start
- match letters repeated one or more times
- match line end
- grep

$regexp=new regexpBuilder();
$regexp->matchLineStart() //match line start
->matchOneOfTheseChars(LETTER_CHAR)->oneOrMoreTimes() //match letters repeated one or more times
->matchLineEnd(); //match line end

$input=array("abc"," ",".","def","");

"Test: array(\"abc\",\" \",\".\",\"def\",\"\");<br>";
"Result: ".print_r($result,true)."<br>"; //Array ( [0] => abc [3] => def )