首页 > 解决方案 > SQL 正则表达式抛出状态=42000,代码=40000

问题描述

case regexp_extract(network_information,'^([\\w|-]+)[.|;].*',1) then .........

对于这部分代码,我得到ParseException line 22:2 cannot identify input near '*' ',' 'case' in expression specification (state=42000,code=40000) 谁能帮帮我。

标签: sqlregexcasehiveql

解决方案


regexp看起来挺好的。案例是错误的。它应该是这样的:

case when regexp_extract(network_information,'^([\\w|-]+)[.|;].*',1) = 'something'
         then ...
 end

或者像这样:

case regexp_extract(network_information,'^([\\w|-]+)[.|;].*',1)
     when 'something'      then ...
     when 'something-else' then ...
 end

推荐阅读