kikee1222
kikee1222

Reputation: 2016

Regex, select the number after a particular string

I have the below string:

rollover#7500,another1#3000,another2#4000, another1#7000

I need to extract the number that comes directly after rollover#

So far, I have this, but it's matching rollover#7500

(?:rollover#[0-9]*)

I'm not sure how to extract only the numbers?

I will be running this in a Hive query

Upvotes: 1

Views: 88

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626929

You may use

regexp_extract(your_col,'rollover#([0-9]+)', 1)

The rollover#([0-9]+) pattern will find rollover# and then will capture 1 or more digits into Group 1, the third 1 argument will make regexp_extract return just the Group 1 value.

Upvotes: 1

Related Questions