i have to fetch model no. col data from ivm col. data.
| ivm | model no |
|---|---|
| 534643-240-0671258 | 0671258 |
| 2894262-101107-V5009-L | V5009-L |
| 732189-149-NV51K6650SS | NV51K6650SS |
| 1139081-97531-PB1100PS1 | PB1100PS1 |
| 89234-79794-T10358-4-CP | T10358-4-CP |
| 2591217-104703-AGAKN95 | AGAKN95 |
| 793509-81227-79246-RB | 79246-RB |
CodePudding user response:
On BigQuery we can try using REGEXP_EXTRACT:
SELECT ivm, REGEXP_EXTRACT(ivm, r'(?:[^-] -){2}(.*)') AS model_no
FROM yourTable;
Here is an explanation of the regex pattern used:
(?:[^-] -){2} match ABC123-DEF456- (i.e. first 2 terms)
(.*) then capture everything else which follows
CodePudding user response:
Consider below approach (BigQuery) - I think in this option regexp is much easier to swallow :o) - it just looks for two groups of digits at the beginning and simply removes them - leaving exactly what you are looking for - which is the rest of string
select ivm, regexp_replace(ivm, r'^\d -\d -', '') as model_no
from your_table
if applied to sample data in your question - output is

