In netscape bookmark files, there are lots of lines like this:
<DT><A HREF="http://www.commondream s.org/" ADD_DATE="10915 00674"
LAST_CHARSET="I SO-8859-1" ID="rdf:#$uiYyb 3">Common Dreams</A>
I want to eliminate the excess attributes and values to get this:
<DT><A HREF="http://www.commondream s.org/">Common Dreams</A>
I almost succeed with this:
$lines[]=preg_replace(" {(<A HREF=\".*\")( ADD.*)(>.*</A>)}","\\1\\3" ,
$line);
The only problem is the explicit "ADD". The code only works is there is
an ADD_DATE attribute immediately after the url. I tried replacing (
ADD.*) with ( .*), which I thought would match everything up to the ">":
$lines[]=preg_replace(" {(<A HREF=\".*\")( .*)(>.*</A>)}","\\1\\3" , $line);
For some reason, this does not find a match. Since " ADD" is the same as
..*, I don't understand why I need the explicit " ADD".
How do I match without the explicit " ADD"
<DT><A HREF="http://www.commondream s.org/" ADD_DATE="10915 00674"
LAST_CHARSET="I SO-8859-1" ID="rdf:#$uiYyb 3">Common Dreams</A>
I want to eliminate the excess attributes and values to get this:
<DT><A HREF="http://www.commondream s.org/">Common Dreams</A>
I almost succeed with this:
$lines[]=preg_replace(" {(<A HREF=\".*\")( ADD.*)(>.*</A>)}","\\1\\3" ,
$line);
The only problem is the explicit "ADD". The code only works is there is
an ADD_DATE attribute immediately after the url. I tried replacing (
ADD.*) with ( .*), which I thought would match everything up to the ">":
$lines[]=preg_replace(" {(<A HREF=\".*\")( .*)(>.*</A>)}","\\1\\3" , $line);
For some reason, this does not find a match. Since " ADD" is the same as
..*, I don't understand why I need the explicit " ADD".
How do I match without the explicit " ADD"
Comment