url-highlight
url-highlight copied to clipboard
Emails are incorrectly recognized as URL.
Hello @DylanBack 👋 Thank you for your interest in Url highlight library.
I'm not sure if I get your issue correctly. There is a way to disable email matching. It cold be done by providing Validator instance with 4th argument (matchEmails) as false
. See corresponding validator documentation section for details.
Here is a small example with disabled email matching:
<?php
require __DIR__ . '/vendor/autoload.php';
use VStelmakh\UrlHighlight\UrlHighlight;
use VStelmakh\UrlHighlight\Validator\Validator;
$validator = new Validator(true, [], [], false);
$urlHighlight = new UrlHighlight($validator);
$result = $urlHighlight->getUrls('Match example.com but not [email protected]');
var_dump($result);
// Output:
//
// array(1) {
// [0]=>
// string(11) "example.com"
// }