MaheshMohan
MaheshMohan

Reputation: 59

Extract only the First set of numbers in a String

I have a string like below:

input = Test_8234_and_2345_end
REG_EXTRACT(input,'(\d+)',1)

I'm trying to create a regex that targets only the first set of numbers (i.e 8234) in the above string but it it returns none. what is wrong with my above code.

Upvotes: 1

Views: 838

Answers (1)

Clay Raynor
Clay Raynor

Reputation: 316

I'm not familiar with Informatica, but the following Regex pattern should work if you disable the greedy global modifier for the pattern:

(?<=_)[0-9]*

I used the regex101.com online regex calculator to test the pattern and it worked with Python.

Upvotes: 1

Related Questions