views:

35

answers:

1

hi 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  A: 

Try this code using php .

<?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
pavun_cool
@pavun_cool please check the edit section of my question
coderex
@coderex: simply changing his expression to `/^(Index\:)(.*)$/` should work.
prodigitalson