cancel
Showing results for 
Search instead for 
Did you mean: 

Why regular expression doesn't work with bracket?

vivo
New Contributor III

I have below codes. Why the regular expression doesn't work with {2}? The last 2 lines should be 1b instead. How to make it work? Thanks.

 

"42" like "[0-9][0-9]"; // i.e. 1b
"42" like "[0-9]{2}"; // i.e. 0b
"42" like "[0-9]{2,2}"; // i.e. 0b

 

1 ACCEPTED SOLUTION

rocuinneagain
Valued Contributor
Valued Contributor
2 REPLIES 2

gyorokpeter-kx
Contributor
Contributor

The patterns used by like are not actual regular expressions, so they don't support this {n} syntax. I think the naming is unfortunate.

Regular expressions in q | Basics | q and kdb+ documentation - Kdb+ and q documentation (kx.com)

rocuinneagain
Valued Contributor
Valued Contributor

kdb+ does not implement full regex.

https://code.kx.com/q/basics/regex/

It supports ? * [] ^

 

If you want full support you can use the C interface to bring in external libraries