Regex: diferència entre les revisions
Salta a la navegació
Salta a la cerca
(Es crea la pàgina amb « /text/ Sensible a majuscules /text/i Insensible a majuscules [^>] Any character except > ? lazy search (as small as possible) :.+?: any amount of character bet...».) |
(Cap diferència)
|
Revisió del 20:03, 16 gen 2013
/text/ Sensible a majuscules /text/i Insensible a majuscules
[^>] Any character except > ? lazy search (as small as possible) :.+?: any amount of character between : and : (but at least one) :.*?: any amount of character between : and : ("::" is ok) :[^:]: should be the same
() Exports data to $match[1], second () to $match[2] $match[0] is everything
preg_match_all('/\[(.*?) (.*?)\].*?: (.*?);.*?idle=(.*?)% user=(.*?)% system=(.*?)% iowait=(.*?)%/i', $text, $match); for ($i = 0; $i < count($match[1]); $i ++) { $file = "nagiossnap/" . $match[3][$i] . ".txt"; file_put_contents($file, $match[1][$i] . "\t" . $match[2][$i]. "\t" . $match[4][$i]. "\t" . $match[5][$i] . "\t" . $match[6][$i] . "\t" . $match[7][$i] . "\n", FILE_APPEND | LOCK_EX); print $match[1][$i]; print $match[2][$i]; print $match[3][$i]; print $match[4][$i]; print $match[5][$i]; print $match[6][$i]; print $match[7][$i]; (...)
Example taken form here: http://esa.espai.de/Logica_client-logica