Search code examples
google-sheetsre2

Extracting a numeric string from URL


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.


Solution

  • 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