Re: Converting SED expression to preg_match()
| From: | shiplu | Date: | Sun, 13 Dec 2015 11:10:46 +0000 |
| Subject: | Re: Converting SED expression to preg_match() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325287@lists.php.net to get a copy of this message | ||
Extracting with XPath is much easier. Why bother regex?
$doc = new DOMDocument();
$doc->loadHTMLFile("yourfile.html");
$xpath = new DOMXPath($doc);
$nodes = $xpath->query('//pre/span//text()');
foreach($nodes as $node){
echo $node->nodeValue. "\n";
}
This prints
http://paste.ubuntu.com/13987562/
On Sun, Dec 13, 2015 at 3:41 PM, Danny <mynixmail@gmail.com> wrote:
> Hi guys,
>
> I am trying to convert the following SED line to do the same thing in
> preg_match() ...
>
> sed -netP -e's/<br>[[:alpha:]][0-9]\{3}[^<]*<br>/\n&\n/;D;:P'
> -eP\;D
>
> Any pointers would be appreciated ...
>
> more infor can be found here:
>
> unix.stackexchange.com/questions/247730/regular-expression-not-matching-all-possibilities
>
> Thank You
> Danny
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Shiplu.Mokadd.im
Unix Hacker
*Innovation distinguishes between follower and leader *
— Steve Jobs
*An expert is a person who has made all the mistakes that can be made in a
very narrow field.*— Neils Bohr