How to find Cyrillic font (russian characters)?

隐身守侯 提交于 2019-12-25 11:56:52

问题


Idea is to find all values that contains Cyrillic font (russian characters).

Something like:

SELECT CASE 
         WHEN Name LIKE /* Cyrillic font / russian characters */ THEN '1' 
         ELSE Name 
       END AS Filter

I can't find any info about It, so I can't provide what I've tried.

For example:

  Name
Александр -- This is Cyrillic (have russian characters, should return 1)
John      -- This should be returned as normal Name

Have you any ideas?


回答1:


As per comment:

This Q&A gives a good way of doing this in SQL-Server (Can't mark as duplicate, since it is a different kind of question):

Solution:

select *,                               --  ▼ space added here
       case when TheName like '%[^-A-Za-z0-9 /.+$]%'
         then '1'
         else TheName
      end as 'Filter'
  from CyrillicTest

You can either adjust the RegEx string to match all the Cyrillic characters or adjust it to cater for hyphenated ASCII names (and all other weird things parents put into their kids names). I am not sure about the speed of this against a big table, so please test it.

Testbed:

create table CyrillicTest
     ( TheID   int identity(1,1) not null,
       TheName nvarchar(50)      not null )

insert CyrillicTest
     ( TheName )
values
     ( 'AName' ),
     ( 'Александр' ),
     ( 'CName' )

Output:

TheID       TheName       Filter
----------- ------------- -------------
1           AName         AName
2           Александр     1
3           Thirdname     Thirdname


来源:https://stackoverflow.com/questions/31606271/how-to-find-cyrillic-font-russian-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!