Reputation: 4516
Data to work with is ...deliveryProfilID: 22261,offerID: '83627489',productKindID: '2',...
It's irregular string from which I have to pull digits of offerID
So I need regex to return 83627489
I got working one but it's awful: offerID\s{0,}:\s{0,}'(\d*)'\s{0,}
I want to use something like this: offerID.*(\d*)
but it selects to much.
Upvotes: 0
Views: 34
Reputation: 4572
offerID[\s]*:[\s]*'(\d*)'
is probably more readable?
but as sp00m said...
offerID\s*:\s*'(\d)'
is already better.
and Avinash Raj's suggestion of
offerID[\D]*(\d*)'
might be my favorite but the brackets aren't necessary.
offerID\D*(\d*)'
Works too.
Upvotes: 0
Reputation: 122383
A little modification would work:
offerID\D*(\d*)
Unlike .*
, \D*
only matches non-digits. And of course you can further improve it if needed:
offerID:\D*'(\d*)'
Upvotes: 1