PHP Classes

File: tests/escaping.php

Recommend this page to a friend!
  Classes of Patrick Van Bergen  >  PHP Regex Builder  >  tests/escaping.php  >  Download  
File: tests/escaping.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: 563 bytes
 

Contents

Class file image Download
<?php

// characters that match delimiters
test('#a/b#',
   
R::expression()->text('a/b')
);

// text with meta characters
test('/\\\\\\^\\$\\.\\[\\]\\|\\(\\)\\?\\*\\+\\{\\}/',
   
R::expression()->text('\\^$.[]|()?*+{}')
);
test('/(\\\\\\^\\$\\.\\[\\]\\|\\(\\)\\?\\*\\+\\{\\})/',
   
R::expression()->group(R::group()->text('\\^$.[]|()?*+{}'))
);

// characters with meta characters
test('/[\\\\^$.[\\]|()?*+{}]/',
   
R::expression()->inChars(R::chars('\\^$.[]|()?*+{}'))
);
test('/[\\\\^$.[\\]|()?*+{}]/',
   
R::expression()->inChars(R::chars()->char('\\^$.[]|()?*+{}'))
);

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