I am trying to extract the number present in a string in which the string comes in a different way. The String I receive and expected output is mentioned below.
| PRODUCT_DESCRIPTION | EXPECTED PACK SIZE | CURRENT_RESULT |
|---|---|---|
| PRODUCT A 3 CHEESE SLICE 170 GM | 170 | 3170 |
| PRODUCT B SUGAR 1.3KG (CL) | 1300 | 13 |
| PRODUCT C CHEESE SLICES 12X156GM | 156 | 12156 |
| PRODUCT KETCHUP BOTTLE 200GM (CL) | 200 | 200 |
| PRODUCT KETCHUP 1.3KG (CL) | 1300 | 13 |
| KITCHEN 88 KALE & CHIA BASMATI RICE 150GM | 150 | 88 |
I tried using below transformation in Snowflake SQL, but it is only extracting all the numerical literals from the string.
REGEXP_REPLACE(SPLIT_PART(UPPER(PRODUTC_DESCRIPTION),'GM',1),'[^[:digit:]]')
I need to run the code in Snowflake, Any help would be appreciated.
Thanks