export doctype from url
Posted: Sat May 17, 2008 7:56 am
Hi ,
I have a variable that saves the whole line doctype of a page using regular expression
So the variable contains the string "<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">"
But I would like to save only SVG 1.1 Basic.
So I am trying to make a regular expression for it like this :
$res = str_replace("(.*)//DTD","", $res);
$res = str_replace("(^//EN) .* (dtd\")$","", $res);
What am I doing wrong ?
Thank you
P.S. : If you know could you help me and for encoding?
I have a variable that saves the whole line doctype of a page using regular expression
Code: Select all
function get_doctype($file){
$h1tags = preg_match('/<!DOCTYPE (\w.*)dtd">/is',$file,$patterns);
$res = array();
array_push($res,$patterns[0]);
array_push($res,count($patterns[0]));
return $res;
}"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">"
But I would like to save only SVG 1.1 Basic.
So I am trying to make a regular expression for it like this :
$res = str_replace("(.*)//DTD","", $res);
$res = str_replace("(^//EN) .* (dtd\")$","", $res);
What am I doing wrong ?
Thank you
P.S. : If you know could you help me and for encoding?