Home > Enterprise >  Using REGEX_EXTRACT in SQL Google BigQuery to extract a string of numbers and letters between second
Using REGEX_EXTRACT in SQL Google BigQuery to extract a string of numbers and letters between second

Time:09-30

I'm looking to use REGEX_EXTRACT in Google BigQuery to extract 178GSKT19824 from the link below.

I tried a few variations of this: sample.com/.*/(.*).html. but it still returns the entire url instead of the needed string.

https://www.sample.com/avantco-178gskt19824-door-gasket-for-gdc-12f-and-gdc-12f-hc-merchandiser-freezers/178GSKT19824.html?utm_source=google&utm_medium=cpc&utm_campaign=GoogleShopping

CodePudding user response:

to use regex to capture everything between the first two '-' characters, you can use \-(.*?)\-

CodePudding user response:

If you want to capture all non / characters before .html use a lookahead:

[^\/]*(?=\.html)

Demo

  • Related