PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $str = '<p>this <a href="https://api.slack.com/apps/" target="_blank">link</a> and <a href="https://www.google.com" target="_blank">link 2</a></p>'; $reg = '/<a.*href="([^"]+)"[^>]+>(.+)<\/a>/'; preg_match_all($reg, $str, $m); $res = preg_replace($reg, '\[$1|$2\]', $str); echo preg_replace('/[([^"]+)]|(.+)]/', '$1 $2', $res);
Show:  
Copy Clear