I'm trying to categorize my sites but they have not always the same uri-structure so I want to extract the year in one column and in the second one I want to extract the month.
The results should be year and months in seperate columns/fields:
| url | year | months |
|---|---|---|
| /www.site.com/path1/resort/2021/02/sitename | 2021 | 02 |
| /www.site.com/path1/2021/02 | 2021 | 02 |
| /www.site.com/path1/2020/11-12 | 2020 | 11-12 |
| /www.site.com/path1/2020/07-08 | 2020 | 07-08 |
| /www.site.com/path1/resort/ | null | null |
the following regex for the year worked:
REGEXP_EXTRACT(url,'([0-9]{4})') >> result: 2020, null etc.
but the regex for the month didnt extract only the months:
REGEXP_EXTRACT(url,'((?:[0-9]{4}/)[0-9]+.?[0-9]*/)') >> result: 2020/11-12/,2021/02/, null etc.
Thanks for the help in advance.