Clickhouse查询使用正则表达式

问题描述

我知道clickhouse提供了replaceRegexpOne()函数,但是我想使用正则表达式来查询而不是替换。像MysqL

select username 
from table 
where username  REGEXP '^[0-9]*$'.

希望您能帮助我,谢谢。

解决方法

我猜您正在寻找match()

match(haystack,pattern)

检查字符串是否与模式正则表达式匹配。 re2正则表达式。 re2正则表达式的语法比Perl正则表达式的语法更受限制。

WHERE match(column,'pattern')

https://clickhouse.tech/docs/en/sql-reference/functions/string-search-functions/#matchhaystack-pattern