如何在Hive中使用rlike来逃避反斜杠和问号字符

时间:2021-09-22 16:27:28

I have a hive query to filter out '/s?' from the data but it doesn't seem to work and I am getting very broad matches

我有一个hive查询来过滤掉'/ s?'从数据,但它似乎没有工作,我得到非常广泛的匹配

where colA rlike '/s?'    
where colA rlike '\/s\?'

both cases return same results even if I escape the characters

即使我逃避了字符,这两种情况都返回相同的结果

1 个解决方案

#1


2  

The / does not need escaping and ? can be either escaped as \\ or just put it into a char class - [?].

/不需要转义和?可以转义为\\或者只是将其放入char类 - [?]。

Use

where colA rlike '/s[?]'

#1


2  

The / does not need escaping and ? can be either escaped as \\ or just put it into a char class - [?].

/不需要转义和?可以转义为\\或者只是将其放入char类 - [?]。

Use

where colA rlike '/s[?]'