note 64213 added to function.preg-replace
| From: | Eric at osu1 dot php dot net | Date: | Mon, 10 Apr 2006 06:54:45 +0000 |
| Subject: | note 64213 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107681@lists.php.net to get a copy of this message | ||
Here recently I needed a way to replace links (<a
href="blah.com/blah.php">Blah</a>) with their anchor text, in this case Blah. It
might seem simple enough for some..or most, but at the benefit of helping others:
<?php
$value = '<a href="http://www.domain.com/123.html">123</a>';
echo preg_replace('/<a href="(.*?)">(.*?)<\\/a>/i', '$2',
$value);
//Output
// 123
?>
----
Server IP: 216.194.113.175
Probable Submitter: 65.81.211.32
----
X-Spam-Status: No, hits=4.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_30_40,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/note/edit/64213
Del: integrated -- http://master.php.net/note/delete/64213/integrated
Del: useless -- http://master.php.net/note/delete/64213/useless
Del: bad code -- http://master.php.net/note/delete/64213/bad+code
Del: spam -- http://master.php.net/note/delete/64213/spam
Del: non-english -- http://master.php.net/note/delete/64213/non-english
Del: in docs -- http://master.php.net/note/delete/64213/in+docs
Del: other reasons-- http://master.php.net/note/delete/64213
Reject -- http://master.php.net/note/reject/64213
Search -- http://master.php.net/manage/user-notes.php