Advertisement
SqlQuantumLeap

T-SQL query and results for filtering types of characters

May 20th, 2016
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 14.55 KB | None | 0 0
  1. -- The results below pertain to the following DBA.StackExchange answer:
  2. -- Is there a T-SQL equivalent for punctuation as [0-9] is for numbers and [a-z] is for letters? ( https://dba.stackexchange.com/a/139132/30859 )
  3.  
  4. -- Please note that the RegEx function, SQL#.RegEx_IsMatch, is not a SQL Server built-in function. It is a
  5. -- SQLCLR function that comes with the Free version of the SQL# library (which I created), available at:
  6. -- https://SQLsharp.com
  7.  
  8. -- Unicode Category info found at:
  9. -- https://www.regular-expressions.info/unicode.html#category
  10.  
  11. ;WITH nums AS
  12. (
  13.      SELECT TOP (256) (ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) - 1) AS [DecimalValue]
  14.      FROM   [master].[sys].[all_objects]
  15. )
  16. SELECT CONVERT(CHAR(3), nm.DecimalValue) + SPACE(8) AS [DecimalValue],
  17.        CHAR(nm.[DecimalValue]) + SPACE(12) AS [Character],
  18.        CASE WHEN CHAR(nm.[DecimalValue]) LIKE '%[^a-z0-9]%'
  19.                THEN 'x' ELSE ' ' END + SPACE(10) AS [Latin1_General_CI_AS],
  20.        CASE WHEN CHAR(nm.[DecimalValue]) LIKE '%[^a-z0-9A-Z]%' COLLATE Latin1_General_100_BIN2
  21.                THEN 'x' ELSE ' ' END + SPACE(12) AS [Latin1_General_100_BIN2],
  22.        CASE WHEN SQL#.RegEx_IsMatch(CHAR(nm.[DecimalValue]), N'\p{P}', 1, NULL) = 1
  23.                THEN 'x' ELSE ' ' END AS [RegExUnicodeCategory]
  24. FROM   nums nm;
  25.  
  26. -- ============================================================
  27. -- =          RESULTS:
  28. -- ============================================================
  29. /*
  30.  
  31.                         Latin1_    Latin1_      RegEx
  32. Decimal    Character    General    General      Unicode
  33. Value                   _CI_AS     _100_BIN2    Category
  34. 0                       x          x            
  35. 1                       x          x            
  36. 2                       x          x            
  37. 3                       x          x            
  38. 4                       x          x            
  39. 5                       x          x            
  40. 6                       x          x            
  41. 7                       x          x            
  42. 8                       x          x            
  43. 9                       x          x            
  44. 10                      x          x            
  45. 11                     x          x            
  46. 12                     x          x            
  47. 13                      x          x            
  48. 14                      x          x            
  49. 15                      x          x            
  50. 16                      x          x            
  51. 17                      x          x            
  52. 18                      x          x            
  53. 19                      x          x            
  54. 20                      x          x            
  55. 21                      x          x            
  56. 22                      x          x            
  57. 23                      x          x            
  58. 24                      x          x            
  59. 25                      x          x            
  60. 26                      x          x            
  61. 27                      x          x            
  62. 28                      x          x            
  63. 29                      x          x            
  64. 30                      x          x            
  65. 31                      x          x            
  66. 32                      x          x            
  67. 33         !            x          x            x
  68. 34         "            x          x            x
  69. 35         #            x          x            x
  70. 36         $            x          x            
  71. 37         %            x          x            x
  72. 38         &            x          x            x
  73. 39         '            x          x            x
  74. 40         (            x          x            x
  75. 41         )            x          x            x
  76. 42         *            x          x            x
  77. 43         +            x          x            
  78. 44         ,            x          x            x
  79. 45         -            x          x            x
  80. 46         .            x          x            x
  81. 47         /            x          x            x
  82. 48         0                                    
  83. 49         1                                    
  84. 50         2                                    
  85. 51         3                                    
  86. 52         4                                    
  87. 53         5                                    
  88. 54         6                                    
  89. 55         7                                    
  90. 56         8                                    
  91. 57         9                                    
  92. 58         :            x          x            x
  93. 59         ;            x          x            x
  94. 60         <            x          x            
  95. 61         =            x          x            
  96. 62         >            x          x            
  97. 63         ?            x          x            x
  98. 64         @            x          x            x
  99. 65         A                                    
  100. 66         B                                    
  101. 67         C                                    
  102. 68         D                                    
  103. 69         E                                    
  104. 70         F                                    
  105. 71         G                                    
  106. 72         H                                    
  107. 73         I                                    
  108. 74         J                                    
  109. 75         K                                    
  110. 76         L                                    
  111. 77         M                                    
  112. 78         N                                    
  113. 79         O                                    
  114. 80         P                                    
  115. 81         Q                                    
  116. 82         R                                    
  117. 83         S                                    
  118. 84         T                                    
  119. 85         U                                    
  120. 86         V                                    
  121. 87         W                                    
  122. 88         X                                    
  123. 89         Y                                    
  124. 90         Z                                    
  125. 91         [            x          x            x
  126. 92         \            x          x            x
  127. 93         ]            x          x            x
  128. 94         ^            x          x            
  129. 95         _            x          x            x
  130. 96         `            x          x            
  131. 97         a                                    
  132. 98         b                                    
  133. 99         c                                    
  134. 100        d                                    
  135. 101        e                                    
  136. 102        f                                    
  137. 103        g                                    
  138. 104        h                                    
  139. 105        i                                    
  140. 106        j                                    
  141. 107        k                                    
  142. 108        l                                    
  143. 109        m                                    
  144. 110        n                                    
  145. 111        o                                    
  146. 112        p                                    
  147. 113        q                                    
  148. 114        r                                    
  149. 115        s                                    
  150. 116        t                                    
  151. 117        u                                    
  152. 118        v                                    
  153. 119        w                                    
  154. 120        x                                    
  155. 121        y                                    
  156. 122        z                                    
  157. 123        {            x          x            x
  158. 124        |            x          x            
  159. 125        }            x          x            x
  160. 126        ~            x          x            
  161. 127                     x          x            
  162. 128        €            x          x            
  163. 129                     x          x            
  164. 130        ‚            x          x            x
  165. 131        ƒ            x          x            
  166. 132        „            x          x            x
  167. 133        …            x          x            x
  168. 134        †            x          x            x
  169. 135        ‡            x          x            x
  170. 136        ˆ            x          x            
  171. 137        ‰            x          x            x
  172. 138        Š            x          x            
  173. 139        ‹            x          x            x
  174. 140        Œ            x          x            
  175. 141                     x          x            
  176. 142        Ž            x          x            
  177. 143                     x          x            
  178. 144                     x          x            
  179. 145        ‘            x          x            x
  180. 146        ’            x          x            x
  181. 147        “            x          x            x
  182. 148        ”            x          x            x
  183. 149        •            x          x            x
  184. 150        –            x          x            x
  185. 151        —            x          x            x
  186. 152        ˜            x          x            
  187. 153        ™            x          x            
  188. 154        š            x          x            
  189. 155        ›            x          x            x
  190. 156        œ            x          x            
  191. 157                     x          x            
  192. 158        ž            x          x            
  193. 159        Ÿ            x          x            
  194. 160                     x          x            
  195. 161        ¡            x          x            x
  196. 162        ¢            x          x            
  197. 163        £            x          x            
  198. 164        ¤            x          x            
  199. 165        ¥            x          x            
  200. 166        ¦            x          x            
  201. 167        §            x          x            
  202. 168        ¨            x          x            
  203. 169        ©            x          x            
  204. 170        ª            x          x            
  205. 171        «            x          x            x
  206. 172        ¬            x          x            
  207. 173        ­             x          x            x
  208. 174        ®            x          x            
  209. 175        ¯            x          x            
  210. 176        °            x          x            
  211. 177        ±            x          x            
  212. 178        ²            x          x            
  213. 179        ³            x          x            
  214. 180        ´            x          x            
  215. 181        µ            x          x            
  216. 182        ¶            x          x            
  217. 183        ·            x          x            x
  218. 184        ¸            x          x            
  219. 185        ¹            x          x            
  220. 186        º            x          x            
  221. 187        »            x          x            x
  222. 188        ¼            x          x            
  223. 189        ½            x          x            
  224. 190        ¾            x          x            
  225. 191        ¿            x          x            x
  226. 192        À                       x            
  227. 193        Á                       x            
  228. 194        Â                       x            
  229. 195        Ã                       x            
  230. 196        Ä                       x            
  231. 197        Å                       x            
  232. 198        Æ                       x            
  233. 199        Ç                       x            
  234. 200        È                       x            
  235. 201        É                       x            
  236. 202        Ê                       x            
  237. 203        Ë                       x            
  238. 204        Ì                       x            
  239. 205        Í                       x            
  240. 206        Î                       x            
  241. 207        Ï                       x            
  242. 208        Ð            x          x            
  243. 209        Ñ                       x            
  244. 210        Ò                       x            
  245. 211        Ó                       x            
  246. 212        Ô                       x            
  247. 213        Õ                       x            
  248. 214        Ö                       x            
  249. 215        ×            x          x            
  250. 216        Ø                       x            
  251. 217        Ù                       x            
  252. 218        Ú                       x            
  253. 219        Û                       x            
  254. 220        Ü                       x            
  255. 221        Ý                       x            
  256. 222        Þ            x          x            
  257. 223        ß                       x            
  258. 224        à                       x            
  259. 225        á                       x            
  260. 226        â                       x            
  261. 227        ã                       x            
  262. 228        ä                       x            
  263. 229        å                       x            
  264. 230        æ                       x            
  265. 231        ç                       x            
  266. 232        è                       x            
  267. 233        é                       x            
  268. 234        ê                       x            
  269. 235        ë                       x            
  270. 236        ì                       x            
  271. 237        í                       x            
  272. 238        î                       x            
  273. 239        ï                       x            
  274. 240        ð            x          x            
  275. 241        ñ                       x            
  276. 242        ò                       x            
  277. 243        ó                       x            
  278. 244        ô                       x            
  279. 245        õ                       x            
  280. 246        ö                       x            
  281. 247        ÷            x          x            
  282. 248        ø                       x            
  283. 249        ù                       x            
  284. 250        ú                       x            
  285. 251        û                       x            
  286. 252        ü                       x            
  287. 253        ý                       x            
  288. 254        þ            x          x            
  289. 255        ÿ                       x            
  290.  
  291.  
  292. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement