PHP Classes
elePHPant
Icontem

SL5 preg Content Finder: Find and replace content using regular expression

Recommend this page to a friend!
  Info   View files Example   View files View files (51)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2015-08-13 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 146 This week: 1All time: 8,195 This week: 1,047Up
Version License PHP version Categories
sl5-preg-finder 1GNU General Publi...5.0PHP 5, Text processing
Description Author

This class can find and replace content using regular expression.

It can take regular expressions that define the delimiters that start and end of the content to match.

The class uses given callback functions to define how to replace the content that is found before, after, inside and the delimiters that were found.

Picture of Sebastian Lauffer
Name: Sebastian Lauffer <contact>
Classes: 1 package by
Country: Germany Germany

Details

SL5_preg_contentFinder

a PHP Template Engine class using Perl Compatible Regular Expressions (PCRE)

See complete examples inside example folder or inside the tests folder. :)

Example source conversion :

<pre> a{b{B}}

==>

a[b[B]] </pre> ______________________

Example source conversion : <pre> if(X1){$X1;if(X2){$X2;}}

==>

if(X1)[ ..$X1;if(X2)[ ....$X2; ..] ] </pre> HowTo config conversion for this last example:

$old_open = '{'; $old_close = '}'; $new_open_default = '['; $new_close_default = ']'; $charSpace = "."; $newline = "\r\n"; $indentSize = 2;

now simply start conversion. BTW optional you could use regular expressions and much more. or you could use your own callback function. enjoy :)

try regular expressions online. for example here: https://regex101.com/

______________________

Example source conversion : <pre> a{b{B}}

==>

a 1|[ 1:..b 2|..[ 2:....B 2:..] 1:] </pre> ______________________

  Files folder image Files  
File Role Description
Files folder image.idea (1 file)
Files folder imageexamples (1 directory)
Files folder imagetests (1 file, 2 directories)
Plain text file GNU_GENERAL_PUBLIC..._3_29_June_2007.txt Lic. License
Plain text file LICENSE.txt Lic. License
Plain text file README.md Doc. Auxiliary data
Plain text file SL5_preg_contentFinder.php Class Class source

  Files folder image Files  /  .idea  
File Role Description
  Plain text file .name Data Auxiliary data

  Files folder image Files  /  examples  
File Role Description
Files folder imageAutoHotKey (7 files, 1 directory)

  Files folder image Files  /  examples  /  AutoHotKey  
File Role Description
Files folder imagejs (2 directories)
  Plain text file create_input_file.php Aux. Example script
  Plain text file input_compressed_1.ahk Data Auxiliary data
  Plain text file input_compressed_2.ahk Data Auxiliary data
  Plain text file oneLineDummy.ahk Data Auxiliary data
  Plain text file output_reformatted_2.ahk Data Auxiliary data
  Plain text file Reformatting_Autohotkey_Source.php Example Unit test script
  Plain text file SUtility.ahk Data Auxiliary data

  Files folder image Files  /  examples  /  AutoHotKey  /  js  
File Role Description
Files folder imageGarlic (8 files, 4 directories)
Files folder imagehighlighter-ahk-zenburn-master (3 files, 3 directories)

  Files folder image Files  /  examples  /  AutoHotKey  /  js  /  Garlic  
File Role Description
Files folder imagebin (3 files)
Files folder imagedist (2 files)
Files folder imageresources (3 files)
Files folder imagetests (5 files)
  Plain text file .travis.yml Data Auxiliary data
  Plain text file CHANGELOG.md Data Auxiliary data
  Plain text file CNAME Data Auxiliary data
  Plain text file component.json Data Auxiliary data
  Plain text file garlic.js Data Auxiliary data
  HTML file index.html Doc. Documentation
  Plain text file LICENCE.md Data Auxiliary data
  Plain text file README.md Data Auxiliary data

  Files folder image Files  /  examples  /  AutoHotKey  /  js  /  Garlic  /  bin  
File Role Description
  Plain text file build.sh Data Auxiliary data
  Plain text file minify Data Auxiliary data
  Plain text file test-suite.sh Data Auxiliary data

  Files folder image Files  /  examples  /  AutoHotKey  /  js  /  Garlic  /  dist  
File Role Description
  Plain text file garlic-standalone.min.js Data Auxiliary data
  Plain text file garlic.min.js Data Auxiliary data

  Files folder image Files  /  examples  /  AutoHotKey  /  js  /  Garlic  /  resources  
File Role Description
  Image file favicon.ico Data Auxiliary data
  Image file garlicjs.png Icon Icon image
  Plain text file jquery-1.8.2.min.js Data Auxiliary data

  Files folder image Files  /  examples  /  AutoHotKey  /  js  /  Garlic  /  tests  
File Role Description
  Plain text file expect.js Data Auxiliary data
  Plain text file index.html Data Documentation
  Plain text file mocha.css Data Auxiliary data
  Plain text file mocha.js Data Auxiliary data
  Plain text file tests.js Data Auxiliary data

  Files folder image Files  /  examples  /  AutoHotKey  /  js  /  highlighter-ahk-zenburn-master  
File Role Description
Files folder imagescripts (2 files)
Files folder imagestorage (3 files)
Files folder imagestyles (3 files)
  Plain text file Readme.md Data Auxiliary data
  Plain text file Test-Bonus-GitHub.html Data Documentation
  Plain text file Test.html Data Documentation

  Files folder image Files  /  examples  /  AutoHotKey  /  js  /  highlighter-ahk-zenburn-master  /  scripts  
File Role Description
  Plain text file shBrushAhk.js Data Auxiliary data
  Plain text file shCore.js Data Auxiliary data

  Files folder image Files  /  examples  /  AutoHotKey  /  js  /  highlighter-ahk-zenburn-master  /  storage  
File Role Description
  Plain text file bigTest.html Data Documentation
  Image file preview.png Data Auxiliary data
  Image file preview_github.png Icon Icon image

  Files folder image Files  /  examples  /  AutoHotKey  /  js  /  highlighter-ahk-zenburn-master  /  styles  
File Role Description
  Plain text file shCore.css Data Auxiliary data
  Plain text file shThemeGitHub.css Data Auxiliary data
  Plain text file shThemeZenburn-A.css Data Auxiliary data

  Files folder image Files  /  tests  
File Role Description
Files folder imagePHPUnit (5 files)
Files folder imagetest2 (1 file)
  Plain text file create_1file_withAll_PHPUnit_tests.php Test Unit test script

  Files folder image Files  /  tests  /  PHPUnit  
File Role Description
  Plain text file Callback_Test.php Test Unit test script
  Plain text file DontTouchThis_searchMode_Test.php Test Unit test script
  Plain text file examples_extracted_from_UnitTest.txt Doc. Documentation
  Plain text file getContent_Test.php Test Unit test script
  Plain text file use_BackReference_searchMode_Test.php Test Unit test script

  Files folder image Files  /  tests  /  test2  
File Role Description
  Plain text file SL5_preg_contentFinderTest1.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:146
This week:1
All time:8,195
This week:1,047Up