我正在尝试从段落中提取没有意义或具有某些特殊字符的单词-它们可能是指向
的随机链接我尝试使用正则表达式,但无法获得成功的结果。
输入样本
header("Content-Type: application/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
$query = mysqli_query($connect, "SELECT * FROM `tbl_city_landing_pages` WHERE `city_landing_pages_status` = 1 ORDER BY `city_landing_pages_keyword` ASC");
$total = mysqli_num_rows($query);
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'.PHP_EOL;
while ($city_rows = mysqli_fetch_array($query)) {
echo '<url>'.PHP_EOL;
echo '<loc>'.BX_DOL_URL_ROOT.strtolower(str_replace(array(" ", "/"), array("-", "_"), $city_rows["city_landing_pages_keyword"])).'</loc>'.PHP_EOL;
echo '<lastmod>'.date('Y-m-d').'</lastmod>'.PHP_EOL;
echo '<changefreq>daily</changefreq>'.PHP_EOL;
echo '</url>'.PHP_EOL;
}
echo '</urlset>'.PHP_EOL;
输出样本
The quick brown fox ran over the lazy dog https//kidsnursuery.com/ghyds/
答案 0 :(得分:0)
正如其他人在评论中所说,识别“无意义的单词”的任务实际上要求您定义“无意义”实际上对您的上下文意味着什么。
从字面上回答您的问题,您可能希望查看CheckSpelling()
函数,如果当前或指定的词典中不存在某个单词,该函数将返回False
。您可以按以下方式调用该函数:
Dim items() As String
Dim i As Long
items = Split("The quick brown fox ran over the lazy dog https//kidsnursuery.com/ghyds/", " ")
For i = 0 To UBound(items)
If Not Application.CheckSpelling(items(i)) Then
items(i) = vbNullString
End If
Next
Debug.Print Join(items, " ")