Adithya Kumar
Adithya Kumar

Reputation: 159

Regex Hive not working

I am trying to extract 44 from the String

Created RSA Key 45555 from Intelligent Expense ID 44|54?HOTEL?345555|||||

using Hive regexp_extract.

The regex I currently have is (^\ID\s)\d* and it is not working.

Can somebody help me please

Upvotes: 1

Views: 169

Answers (1)

rock321987
rock321987

Reputation: 11032

^ marks beginning of string which is not always the case, because it does not necessarily start with ID. So you can use

(ID\s)\d*

For capturing only numbers after ID and you should use \d+ instead of \d*

ID\s(\d+)

This capturing group can be accessed using 1 as mentioned here

Upvotes: 1

Related Questions