コード例 #1
0
ファイル: usage.php プロジェクト: strifefrosst/koeZionCMS
/**
* Class : TextSearch
*
* @author  :  MA Razzaque Rupom <*****@*****.**>, <*****@*****.**>
*             Moderator, phpResource Group(http://groups.yahoo.com/group/phpresource/)
*             URL: http://rupom.wordpress.com
*        
* @version :  1.0
* Date     :  06/25/2006
* Purpose  :  Searching and replacing text within files of specified path
*/
require_once 'TextSearch.class.php';
$path = __DIR__ . "/tmp";
//setting search path
$logFile = __DIR__ . "/tmp/searchResult.txt";
//setting log file
$obj = new TextSearch();
$obj->setExtensions(array('html', 'txt'));
//setting extensions to search files within
$obj->addExtension('php');
//adding an extension to search within
$obj->setSearchKey('PHP');
$obj->setReplacementKey('phpResource');
//setting replacement text if you want to replace matches with that
$obj->startSearching($path);
//starting search
$obj->showLog();
//showing log
$obj->writeLogToFile($logFile);
//writting result to log file
コード例 #2
0
<?php

//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2014 by PDFTron Systems Inc. All Rights Reserved.
// Consult LICENSE.txt regarding license information.
//---------------------------------------------------------------------------------------
include "../../../PDFNetC/Lib/PDFNetPHP.php";
// Relative path to the folder containing the test files.
$input_path = getcwd() . "/../../TestFiles/";
$output_path = $input_path . "Output/";
PDFNet::Initialize();
$doc = new PDFDoc($input_path . "credit card numbers.pdf");
$doc->InitSecurityHandler();
$txt_search = new TextSearch();
$mode = TextSearch::e_whole_word | TextSearch::e_page_stop;
$pattern = "joHn sMiTh";
//call Begin() method to initialize the text search.
$txt_search->Begin($doc, $pattern, $mode);
$step = 0;
//call Run() method iteratively to find all matching instances.
while (true) {
    $searchResult = $txt_search->Run();
    if ($searchResult->IsFound()) {
        if ($step == 0) {
            //step 0: found "John Smith"
            //note that, here, 'ambient_string' and 'hlts' are not written to,
            //as 'e_ambient_string' and 'e_highlight' are not set.
            echo nl2br($searchResult->GetMatch() . "'s credit card number is: \n");
            //now switch to using regular expressions to find John's credit card number
            $mode = $txt_search->GetMode();
            $mode |= TextSearch::e_reg_expression | TextSearch::e_highlight;
 private function getFlatFileArray()
 {
     if (!count(self::$flat_file_array)) {
         $array = $this->getFileArray($this->basePath, false);
         $multiDimensionalArray = $this->getFileArray($this->basePath, false);
         //flatten it!
         self::$flat_file_array = new RecursiveIteratorIterator(new RecursiveArrayIterator($multiDimensionalArray));
     }
     return self::$flat_file_array;
 }