Return to Snippet

Revision: 56232
at March 17, 2012 04:20 by rwunsch


Updated Code
/*
 * DO NOT USE THE PATTERN STRING DIRECTLY IN 'preg_match()' !!!!
 *
 */
$pattern = '/(?<=href\=")[^]]+?(?=")/';
$replacedHrefHtml = preg_replace($pattern, $replacement, $html);

Revision: 56231
at March 17, 2012 03:20 by rwunsch


Initial Code
$replacedHrefHtml = preg_replace('/(?<=href\=")[^]]+?(?=")/',$replacement, $html);

Initial URL

                                

Initial Description
Replaces all links within href part of anchor in a HTML-String.

Initial Title
Remove / Replace - href / anchor /link - in html /string - preg_replace - php - regex - regular expression

Initial Tags
regex, html, links

Initial Language
PHP