Clickhouse: Regular expressions in function Clickhouse

Created on 11 Aug 2019  Β·  2Comments  Β·  Source: ClickHouse/ClickHouse

Hello. study ClickHouse. I am interested in the syntax of regular expressions. For example, I need to find string that contain character '2' followed by '3' or '4'. Has tried: '\2[3-4]' not particularly helps. Maybe someone can help, thank you.

question

Most helpful comment


select x, match(x, '2[3-4]') as match from (select arrayJoin(['12345', '224', '125432']) x)

β”Œβ”€x──────┬─match─┐
β”‚ 12345  β”‚     1 β”‚
β”‚ 224    β”‚     1 β”‚
β”‚ 125432 β”‚     0 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜

All 2 comments


select x, match(x, '2[3-4]') as match from (select arrayJoin(['12345', '224', '125432']) x)

β”Œβ”€x──────┬─match─┐
β”‚ 12345  β”‚     1 β”‚
β”‚ 224    β”‚     1 β”‚
β”‚ 125432 β”‚     0 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜

We use re2 syntax that is a limited version of PCRE:
https://clickhouse.yandex/docs/en/query_language/functions/string_search_functions/#match-haystack-pattern

Was this page helpful?
0 / 5 - 0 ratings