
使用 mysql 正则表达式查询含有日文假名的字段
对于查询含有日文平假名和片假名的字段,常规的 regexp 匹配可能不理想。以下是如何使用自定义函数进行准确查询:
`
<br>create definer=wq19bar@% function jp_char_inside(s text) returns int(11)<br>begin</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1821">
<img src="https://img.php.cn/upload/ai_manual/000/969/633/68b6cb7330755575.png" alt="Dreamlike.art">
</a>
<div class="aritcle_card_info">
<a href="/ai/1821">Dreamlike.art</a>
<p>内置5种模型的AI图像生成器</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="Dreamlike.art">
<span>57</span>
</div>
</div>
<a href="/ai/1821" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="Dreamlike.art">
</a>
</div>
<pre class="brush:php;toolbar:false;">declare h text;
declare p integer;
declare l integer;
declare head text;
declare utf_8 text;
set h = hex(s);
set p = 1;
set l = length(h);
while p <= l do
set head = substr(h, p, 1);
if head < '8' then
set p = p + 2;
else
set utf_8 = substr(h, p, 6);
if (utf_8 >= 'E38181' and utf_8 <= 'E3829E') then
return 1;
end if;
if (utf_8 >= 'E382A1' and utf_8 <= 'E383BE') then
return 1;
end if;
set p = p + 6;
end if;
end while;return 0;
end
`
以上就是如何使用 MySQL 正则表达式精确匹配含有日文假名的字段?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号