Quick actions

cmd+k|ctrl+k

Navigation

Languages

URL replace with link (includes period and space)

Snippet info

Language

Php

Visibility

public

Author

myles

Created

2022-02-02T00:09:49.437165Z

Updated

2022-02-02T00:09:49.437165Z

<?php

$s = 'Please visit http://google.com. Then return to our site.';
$r = preg_replace('"<a[^>]+>.+?</a>(*SKIP)(*FAIL)|\b(?:https?)://\S+"', '<a href="$0">$0</a>', $s);

echo $r;
INFO