Вот код для экспорта таблицы HTML в EXcel, CSV, Pdf, Doc
https://plnkr.co/edit/HmKBjYmJNjp8mPzIlg52?p=preview
Export HTML Table to Excel, Pdf, CSV and Doc
Employee ID
Last Name
First Name
Salary
{{item.EmployeeID}}
{{item.LastName}}
{{item.FirstName}}
{{item.Salary}}
Export CSV
Export Excel
Export Doc
Export Pdf
Предполагая, что все варианты определены как имеющие разные типы / количества пробелов, вы можете просто попробовать удалить все пробелы:
$number = "+47 17 93 39 39 3";
$number = preg_replace('/\s+/', '', $number);
Чтобы извлечь свой номер из текста, попробуйте использовать preg_match_all
Пример:
$input = "Infos auch unter whatsapp nummber:+43 68 86 49 45 702";
preg_match_all("/\+?\d+(?:\s+\d+)*/", $input, $matches);
$number = preg_replace('/\s+/', '', $matches[0][0]);
echo $number;
+4368864945702
Вы можете использовать preg_replace_callback()
здесь со следующим выражением:
\+?\d[\s\d]+\d
См. демонстрацию на regex101.com .
PHP
это может быть: <?php
$text = <<<END
That works if the number is as the keyword. E.g. +47179339393. But as the spammer is now entering +47 17 93 39 39 3 and variations of it, it failes.
How could I change the stripos function to make sure that all variant of +47179339393 will be recognized?
Infos auch unter whatsapp nummber:+43 68 86 49 45 702
END;
// put the numbers to ignore inside this array
$ignore = [];
// expression from above
$regex = "~\+?\d[\s\d]+\d~";
$text = preg_replace_callback(
$regex,
function($match) {
$stripped_number = preg_replace("~\s+~", "", $match[0]);
if (in_array($stripped_number, $ignore)) {
return "";
} else {
// leave it untouched
return $match[0];
}
echo $stripped_number;
},
$text);