-1

I was trying to extract this numeric string: 232546102069 from the given link:

http://www.abc.in/itm/fawf-asdfsafjsaf-jasfh-lbadfugo-hasdhf-asdijfh-xpq/232546102069?hash=item3624d3eb35:g:BU4AAOSwm3pZ-cQV  

using regex in Sheets.

Can anyone help me with the logic and its explanation?

Any help would be greatly appreciated.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563

1 Answers1

1

Try matching the following pattern:

http:\/\/www.*\/(\d+)\?

The number you want to capture will be available in the first capture group. I make the assumption here that the 12 digit number you want to capture will always occur immediately before the start of the query string.

Demo

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • for some of the links the regex wasn't capturing the required data. But if i removed 'http:' it worked! Can you please explain that? – Sagar Singh Verma Dec 21 '17 at 11:24
  • The only explanation that comes to mind is that certain of your links do not start with `http`. Maybe they are fragments, or maybe they start with `https` instead. Your sample data is very limited, hence I gave what I thought was the best possible answer. – Tim Biegeleisen Dec 21 '17 at 11:32