PEAR Handbuch | ||
---|---|---|
Zurück | Nach vorne |
With SearchReplace, you can replace a text in as many as desired files by another.
Beispiel 1. typical usage
|
The example replaces all occurences of "Yes" with "No" in the given $files in the directory "/mail/". If a line in a file starts with one of the chars in $ignoreline, possible matches will be ignored.
You can do a new search without creating a new instance of the class.
Beispiel 2. Do a new search
|
File_SearchReplace supports different kinds of search functions. The type directly influence the format of the required $find-parameter
normal - default, the only type supporting the $IgnoreLines -parameter |
quick - use str_replace() |
preg - use preg_replace() |
ereg - use ereg_replace() |
Constructor - sets the search and replace query
Parameter
$find - the string/regex to find
$replace - the string/regex to replace $find
$files - the file(s) to perform this operation on.
$directories - the directories to perform this operation on.
$include_subdir - if performing on directories, whether to traverse subdirectories.
$ignore_lines - ignore lines beginning with any of the strings in this array. This feature only works with the "normal" search.
Accessor to return the number of occurences found.
Returns
integer - Number of occurences found
This starts the search/replace off. Call this to do the search. First do whatever files are specified, and/or if directories are specified do those too.
Accessor for setting find variable.
Parameter
$find - the string/regex to find
Accessor for setting replace variable.
Parameter
$replace - the string/regex to replace the find string/regex with.
Accessor for setting files variable.
Parameter
$files - the file(s) to perform this operation on.
Accessor for setting directories variable.
Parameter
$directories - the directories to perform this operation on.
Accessor for setting include_subdir variable.
Parameter
$inlude_subdir - Whether to traverse subdirectories or not.
Accessor for setting ignore_lines variable.
Parameter
$ignore_lines - Ignore lines beginning with any of the strings in this array. This feature only works with the "normal" search.
Function to determine which search function is used.
Parameter
$search_function - The search function that should be used. See "Types of search functions"
Zurück | Zum Anfang | Nach vorne |
File_Passwd | Nach oben | Logging |