gpt4 book ai didi

regex - postgres 正则表达式查找字符\u0001 到\u0031

转载 作者:行者123 更新时间:2023-11-29 12:14:36 31 4
gpt4 key购买 nike

如何在 postgres 列值中找到所有空白字符,如\u0004 或\u0001?它可以在开头、中间或结尾。我不想获得空格 (\u0032) 值,只包含从\u0001 到\u0031 的空白字符。

类似下面的内容,但它也选择了空格是不正确的???

select column where column ~* '[\u0001-\u0031]'

谢谢

最佳答案

您可能会混淆 \uwxyz以十进制为基数的格式。检查 Unicode 的 C0 Controls and Basic Latin图表来确定。我猜你想要 C0 控制范围从 U+0001 到 U+001F,所以你可以写:

SELECT  E'\u0033 dfgdgdg' ~ E'[\\u0001-\\u001F]' AS isMatch;

或使用八进制基数\xyz:

SELECT  E'\u0033 dfgdgdg' ~ E'[\\001-\\037]' AS isMatch;

另一种方便的方法是用 dollar quoting 编写模式(所以你不需要另外转义反斜杠):

$$[\u0001-\u001F]$$
$$[\x001-\x01f]$$
$$[\001-\037]$$

关于regex - postgres 正则表达式查找字符\u0001 到\u0031,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6739276/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com