PHP Classes

File: tests/expressions.php

Recommend this page to a friend!
  Classes of Patrick Van Bergen  >  PHP Regex Builder  >  tests/expressions.php  >  Download  
File: tests/expressions.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Regex Builder
Generate regular expression strings from rules
Author: By
Last change:
Date: 5 years ago
Size: 1,184 bytes
 

Contents

Class file image Download
<?php

// empty
test('//', R::expression());

// startOfString
test('/^/',
   
R::expression()->startOfString()
);

// endOfString
test('/$/',
   
R::expression()->endOfString()
);

// text
test('/Lady Lovelace/',
   
R::expression()->text('Lady Lovelace')
);

// or
test('/master|maestro|mister/',
   
R::expression()->oneOfThese()->text('master')->text('maestro')->text('mister')
);

// delimiters
test('#/#',
   
R::expression()->text('/')
);
test('%/#%',
   
R::expression()->text('/#')
);

// wordBoundary
test('/\b/',
   
R::expression()->wordBoundary()
);

// anythingButWordBoundary
test('/\B/',
   
R::expression()->anythingButWordBoundary()
);

// startOfStringOrLine
test('/^/m',
   
R::multiLineExpression()->startOfStringOrLine()
);

// endOfStringOrLine
test('/$/m',
   
R::multiLineExpression()->endOfStringOrLine()
);

// startOfString
test('/\A/m',
   
R::multiLineExpression()->startOfString()
);

// endOfString
test('/\Z/m',
   
R::multiLineExpression()->endOfString()
);

// endOfStringOrNewlineAtEnd
test('/\z/m',
   
R::multiLineExpression()->endOfStringOrNewlineAtEnd()
);

// backReference
test('/(abc) \1/',
   
R::expression()
        ->
group(R::group()->text('abc'))
        ->
text(' ')
        ->
backReference(1)
);

For more information send a message to info at phpclasses dot org.