PHP ve C svn diff dosyadan dosya yolunu almak

1 Cevap php

I have a file having svn diff i wish to extract the filenames form the diff. How to write the parser for that..

Index: libs / constant.php
===================================================================
--- libs / constant.php   (revision 1243)
+++ libs / constant.php   (revision 1244)
@@ -26,5 +26,5 @@
 // changesss
-
+// test 2
 ?>
\ No newline at end of file
Index: libs / Tools.php
===================================================================
--- libs / Tools.php  (revision 1243)
+++ libs / Tools.php  (revision 1244)
@@ -34,5 +34,5 @@
 // another file an change
-
+// test
 ?>
\ No newline at end of file

Sample output.

libs / constant.php

libs / Tools.php

EDIT: The File name might be different .php .inc .. etc.. How to write parser in PHP and C.

1 Cevap

Php kullanarak bu kodu deneyin.

<?php
$fh = fopen('file.txt','rb');
for ($line = fgets($fh); ! feof($fh); $line = fgets($fh)) {
if  ( preg_match( '/^(Index\:)(.*\.php)$/',$line ,$val ) )
{
print "$val[2]\n" ;
}
}
fclose($fh);
?>
Output:
libs/constant.php
libs/Tools.php