PHP Classes

Matcher Class: Validate values from examples with similar format

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 308 All time: 7,291 This week: 423Up
Version License PHP version Categories
matcher-class 1.0Artistic License5.0Algorithms, PHP 5, Text processing, V...
Description Author

This class can validate values from examples with similar format.

It takes an example value, like for instance an e-mail address or a decimal value, and generates a regular expression based on that value considering a common list of delimiter characters.

The generated regular expression can be used to validate other values with similar format without having to specify that regular expression explicitly.

The class can also find all matches of the specified patterns in a given text string.

It can also search for text that is similar to a pattern.

Additional options may set the matching to be case sensitive or not, limit the length of matched text.

Innovation Award
PHP Programming Innovation award nominee
September 2012
Number 5

Prize: One downloadable copy of Komodo IDE
One way to validate data that needs to match a given format is to use regular expressions.

Regular expressions are powerful but they are also not easy to understand and often are error prone to create them manually.

This class provides an alternative approach to validate data with regular expressions without the need to manually create them.

It just takes a sample valid values and analyzes them to create regular expressions that match the values based on the position of typical delimiter characters.

Manuel Lemos
Picture of Pashkov Denis Igorevich
  Performance   Level  
Name: Pashkov Denis Igorevich <contact>
Classes: 21 packages by
Country: Ukraine Ukraine
Age: 32
All time rank: 3068 in Ukraine Ukraine
Week rank: 170 Up6 in Ukraine Ukraine Up
Innovation award
Innovation award
Nominee: 10x

Winner: 1x

String Matcher Class can be used As simple Regular Expression  Generator  For emails,substrings,etc  
It has setPattern method Which takes   string or array as Example data,  for example  setPatterns("")   will genearete reg exp for email check   
or  setPattern("0.50")  generate  reg exp for decimal match. 
There is also MatchAll  method   which will find  all  matches by pattern in given string.  
for example $clas->setPattern("")->matchAll("Some string  with some emails  like    or  "); will return  array  of email matches. 

// Controll methods 
Method  useEachLength(true||false)
if set to True  will  add  {1..}  Length check  for each part of regular Expression  

Method getRegular() return Generated regualr Expressions; 
Method caseSens(true||false)  set to Generate   case sensative regualar expression match or not. ('/i') 
Method setUseLength(true||false)  if set to true  add length check at the and of regular expression {10...}  so tested string lngth must match to pattern length.

Method  getSimilar() accpet array of strings  
Return strings array that are similar to a pattern  

Method comvertAgains(string )  return array  of strings  that are   transformed    against pattern .   

Method isMatchAll($str)  -  Return True if one of the Patterns Match in Long text string

method SetCorector - >  set Arrayt of  correction values for comvertAgainst Method .. see Example.php

Method  setUseNumb(true)  - add [0-9]  to each Peace of regular expression pattern used when need to match  string with numbers 
Exmple.php  -  is  sets of test that exaplain how it works .  

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Exmaple
Plain text file MathcerClass.php Class Class
Accessible without login Plain text file readme.txt Doc. Readme

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,291
This week:423Up
For more information send a message to info at phpclasses dot org.