03132006 1353 GMT-6

Thanks for that James.

You dont happen to know of any way using a shell script to do that; Do you?
Or are you just saying there is a way - some where.

wade

James Keeline wrote:

>--- Wade Smart <[EMAIL PROTECTED]> wrote:
>
>  
>
>>03112006 1401 GMT-6
>>
>>Im trying write a script that will do this:
>>    I provide a directory location. The script scans all the files in a 
>>directory, oldest to newest. In each file it looks for the word [QUOTE]. 
>>It counts forward until it finds [/QUOTE]. Then it copies the counted 
>>characters. It opens a file titled quotes.txt and runs a scan to see if 
>>that particular quote is in there. If it is not, it pastes it. If it is, 
>>it drops that copied text and returns to the scan.
>>
>>Im a bit stuck on the copy part. Once I find the text, how do I copy it?
>>
>>wade
>>    
>>
>
>This is basically a regular expression issue.  You want to search for some 
>starting and ending
>string and capture the content between these strings.
>
>$content = join("",file("somefilename"));
>$regex = "|\[QUOTE\](.*?)\[/QUOTE\]|is";
>if(preg_match($regex, $content, $matches))
>{
> print "Match found:<br>\n";
> print $matches[1];
>}
>
>Note that my regex uses vertical bars instead of the forward slash to 
>determine the start and end
>of the expression.  This means we don't have to escape the forward slash.  
>However, since the
>square brackets have special meaning in regex, those do have to be escaped to 
>use them as literal
>characters.  The modifiers at the end cause the match to ignore capitalization 
>(i) and allow the
>match to span multiple lines (s).
>
>The .*? finds the shortest match between the two strings.  By placing this 
>pattern in a
>parentheses set the value found is stored in memory and available in the array 
>designated in
>preg_match.  The 0 element is the entire string containing a match (not often 
>useful).  The 1 is
>the first set of parentheses, 2 the second, and so on.
>
>If you expect to have multiple occurrences of this pattern in your document, 
>you will want to use
>preg_match_all which will place the matches in a two-dimensional array.  There 
>are two constants
>used to determine the behavior of the function:  PREG_SET_ORDER and 
>PREG_PATTERN_ORDER.  I usually
>find PREG_SET_ORDER to be more useful.
>
>Keep in mind that there may be a way to do this with a Linux Bash shell script 
>as well.  There are
>many regular expression tools and they can parse through multiple files faster 
>than a PHP script
>can, in general.  The utilities used are compiled C programs and this is a 
>factor.  Plus, they
>have a more direct connection to the filesystem than PHP does.
>
>James
>_____
>
>James D. Keeline
>http://www.Keeline.com  http://www.Keeline.com/articles
>http://Stratemeyer.org  http://www.Keeline.com/TSCollection
>
>http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
>Spring Semester January-June 2006.  Two new class topics.
>
>
>Community email addresses:
>  Post message: [email protected]
>  Subscribe:    [EMAIL PROTECTED]
>  Unsubscribe:  [EMAIL PROTECTED]
>  List owner:   [EMAIL PROTECTED]
>
>Shortcut URL to this page:
>  http://groups.yahoo.com/group/php-list 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
>  
>


[Non-text portions of this message have been removed]



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to