Reputation: 449
I have a few strings
'delivery|1111111'
'order|22222222'
'smth else|3333333'
I need to extract the first sequence of numeric characters after delivery|
or order|
.
If it's just one I do
select regexp_extract('delivery|1111111|22222222', 'delivery\\|(\\d+)', 1);
and get 1111111
, but when I try for both
select regexp_extract('order|22222222|11111111', '(delivery\\|(\\d+)|order\\|(\\d+))', 1);
I get order|22222222
. How do I do it?
Upvotes: 0
Views: 51
Reputation: 2701
If Hive regexes are Java regexes, try this regex: (?:delivery|order)\\|(\\d+)
The problem is that you're using three capturing groups, and the group you're selecting captures the entire string.
Upvotes: 2