提取汉字方法

create table tb(col char(20))
insert into tb values('照片21cm')
insert into tb values('彩图12cm')
insert into tb values('有光盘')
insert into tb values('21cm')
insert into tb values(null)
go

create function f_get_c(@oldstr varchar(100)) returns varchar(100)
as
 
begin
 
declare @i int
 
set @i = 1
 
while @i <= len(@oldstr)
 
if substring(@oldstr, @i, 1) like('[^吖-咗]')
   
set @oldstr = replace(@oldstr, substring(@oldstr, @i, 1), '')
 
else
 
set @i = @i +1
 
return @oldstr
end
go

create function f_get_e(@oldstr varchar(100)) returns varchar(100)
as
 
begin
 
declare @i int
 
set @i = 1
 
while @i <= len(@oldstr)
 
if substring(@oldstr, @i, 1) like('[^a-z,A-Z,0-9]')
   
set @oldstr = replace(@oldstr, substring(@oldstr, @i, 1), '')
 
else
 
set @i = @i +1
 
return @oldstr
end
go

select dbo.f_get_c(col) col_c , dbo.f_get_e(col) col_e from tb where col like('%[^吖-咗]%') or  col like('%[^a-z,A-Z,0-9]%')
union all
select col1 = null,col2 = null from tb where col is null

drop table tb
drop function f_get_e
drop function f_get_c

他的作用是做一个通陪符,意思就是要查找的字符串应该是以中文开头

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Jupyter中提取汉字有几种方法。首先,需要确保你的系统中有中文字体可用。你可以使用matplotlib库来查询当前系统中的所有字体,以查看是否有中文字体可用。可以使用以下代码来查询当前系统中所有字体: ```python from matplotlib.font_manager import FontManager mpl_fonts = set(f.name for f in FontManager().ttflist) print('all font list get from matplotlib.font_manager:') for f in sorted(mpl_fonts): print('\t', f) ``` 这将打印出当前系统中所有可用的字体名称。 如果你没有中文字体可用,你可以下载对应的ttf文件,并将其放置在指定位置。你可以从http://xiazaiziti.com/329416.html下载中文字体的ttf文件。或者,你可以使用以下链接下载中文字体的ttf文件:https://pan.baidu.com/s/1v3kGCeynSSnRidxAJhRXkg?pwd=l91b 提取码:l91b。 下载中文字体ttf文件后,将其放置在系统的特定文件夹中,然后重新运行Jupyter。这样,你就可以在Jupyter中提取并显示汉字了。 另外,如果你想将字典数据转换为XML格式的字符串,并且其中包含了汉字,你可以使用相应的库来实现。比如,你可以从相关库中导入`dicttoxml()`函数来实现这个功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [jupyter matplotlib中文乱码解决](https://blog.csdn.net/weixin_43843494/article/details/129200654)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [利用jupyter提取xml数据集内容存入sql数据库](https://blog.csdn.net/lagoon_lala/article/details/104210239)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值