1

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

rock321987
  • 10,942
  • 1
  • 30
  • 43
Adithya Kumar
  • 159
  • 1
  • 2
  • 12

1 Answers1

1

^ 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

Community
  • 1
  • 1
rock321987
  • 10,942
  • 1
  • 30
  • 43