FluxTorpedoe wrote:Out of curiosity, what would be the advantage in this case of placing a regexmatches inside a foreach?
The foreach() construct splits the whole big $INPUT into parts, here into separate lines ($LINE).
That way the user can work on whole lines containing the pattern.... or on lines they not.
I guess it was the else part why I used foreach() instead of regexmatches() alone.
(or because I know foreach better (longer) than regexmatches ?)
Code: Select all
$INPUT = readfile("<xydata>\xyplorer.ini");
$OUT=""; $BAD="";
foreach($LINE,$INPUT,"<crlf>"){
$TMP = regexmatches($LINE, "tweak");
if($TMP!=""){
$OUT=$OUT.$LINE."<crlf>";
}else{
$BAD=$BAD.$LINE."<crlf>";}
}
text $OUT; text $BAD;
Maybe regexmatches() was not the best example command to explain the foreach() loop,
since regexmatches() can do my example on its own:
Code: Select all
$INPUT = readfile("<xydata>\xyplorer.ini");
$Matches = regexmatches( $INPUT , "^.+tweak.+$" , "<crlf>");
text $Matches;
Was that your concern?
.