I am trying to get the string between parentheses but i am getting always getting empty value.
String_Input: select sum(OUTPUT_VALUE) from table_name
Output : OUTPUT_VALUE
What I tried here:
select regexp_extract(String_Input,"/\\(([^)]+)\\)/") from table_name;
any suggestion to get the value ?
If you need to get the value without the parentheses, you should indicate that you need to extract Captturing group 1 value in the third argument to regexp_extract function. Besides, you should remove / delimiters, they are parsed as literal symbols.
select regexp_extract(String_Input,"\\(([^)]+)\\)", 1) from table_name;
^ ^ ^
From the Hive documentation:
The 'index' parameter is the Java regex
Matcher group()method index. See docs/api/java/util/regex/Matcher.html for more information on the 'index' or Java regexgroup()method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With