Extract Number After Certain Word With Regex

Hi everybody,
I have a column with string which contains also numbers something like this :
hi abc 21 bye 2
good abc 5
abc 890
also noted that there is always a space between abc and number!

what I want is only the numbers after abc :

21
5
890

how can I do this with regex ?

thanks in advance :pray:

1 Like
^[^\d]*(\d+)

Matt

Dear Matt_D,
thanks for your advice, it is working properly except for rows with JUST Numbers in it and not even a single character! for example I have row with just one number in it (Like12345) which this regex recognize it as a result!
How can I include that abc I mention above to this regex ?

I wrote this regex myself (?<=abc\s).[0-9]+ but it doesn’t separate “one digit number” from my data (for example it works when my data is abc 10 but it doesn’t work when it is abc 2!!!)

thanks again for your help

Hi @psfard,

If you remove the period so it becomes
(?<=abc\s)[0-9]+
It should work as currently it is looking for a character after the white space but before the digits, so it ignores a single digit

2 Likes

It is working properly thanks @takbb

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.