\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})
[ ] \ / ^ $ . | ? * + ( ) { }
[\w\.-]+@[\w-]+\.[a-zа-я]{2,10}
http[s]?:\/\/[^\/]+\/
^(https?:\/\/)?([\w\.]+)\.([a-z]{2,6}\.?)(\/[\w\.]*)*\/?$/
^((http|https|ftp):\/\/)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)
(?http://[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]
http[s]?:\/\/
w{3}\.
index\.php|\.php|\.jpg
[a-z0-9]+\.\w+\.?\w+\/(\w+)?[\?\/]?(\w+=?\w)?\/?(\w+)?\/?(\w)?
select distinct title from `business-metric.project.example_final_bitrix24`
select distinct title from `business-metric.project.example_final_bitrix24`
where REGEXP_CONTAINS (title,'Заявка')
select distinct title from `business-metric.project.example_final_bitrix24`
where title like ('Заявка%')
select distinct title,
REGEXP_REPLACE (title,'Заявка от','Клиент') as new_title
from `business-metric.project.example_final_bitrix24`
where title like ('Заявка%')
select distinct source,
REGEXP_EXTRACT(source, 'utm_source=([\\w\\d-_%.]+)') as new_source
from `business-metric.project.example_final_bitrix24`
select title,
REGEXP_EXTRACT (title, r'[А-Яа-я]+') as new_title
from `business-metric.project.example_final_bitrix24`
where title like 'Заявка%'
SELECT
source,
--- Определяем источник
CASE
--- Если у нас есть utm метка, то извлекаем из нее название источника
WHEN REGEXP_CONTAINS(source, 'utm_source.*') THEN REGEXP_EXTRACT(source, 'utm_source=([\\w\\d-_%.]+)(?:&|$)')
--- Если у нас есть просто переход из поисковых систем или социальных сетей, то достаем просто название
WHEN REGEXP_CONTAINS(source, '^https?://(?:www\\.)?(yandex|google|facebook|vk|instagram).*') THEN REGEXP_EXTRACT(source, '^https?://(?:www\\.)?(yandex|google|facebook|vk|instagram).*')
--- Если данные отсутствуют, возвращаем direct
WHEN source = '' THEN '(direct)'
ELSE
--- Иначе берем просто домен без лишнего
REGEXP_EXTRACT(source, '^https?://((?:www\\.)?.*)')
END
AS new_source,
--- Определяем канал
CASE
WHEN REGEXP_CONTAINS(source, 'utm_medium.*') THEN REGEXP_EXTRACT(source, 'utm_medium=([\\w\\d-_%.]+)(?:&|$)')
WHEN REGEXP_CONTAINS(source, '^https?://(?:www\\.)?(yandex|google).*') THEN 'organic'
WHEN REGEXP_CONTAINS(source, '^https?://(?:www\\.)?(facebook|vk|instagram).*') THEN 'social'
WHEN source = '' THEN '(none)'
ELSE
REGEXP_EXTRACT(source, '^https?://((?:www\\.)?.*)')
END
AS medium,
FROM
SELECT
source,
--- Определяем источник
CASE
--- Если у нас есть utm метка, то извлекаем из нее название источника
WHEN REGEXP_CONTAINS(source, 'utm_source.*') THEN REGEXP_EXTRACT(source, 'utm_source=([\\w\\d-_%.]+)(?:&|$)')
--- Если у нас есть просто переход из поисковых систем или социальных сетей, то достаем просто название
WHEN REGEXP_CONTAINS(source, '^https?://(?:www\\.)?(yandex|google|facebook|vk|instagram).*') THEN REGEXP_EXTRACT(source, '^https?://(?:www\\.)?(yandex|google|facebook|vk|instagram).*')
--- Если данные отсутствуют, возвращаем direct
WHEN source = '' THEN '(direct)'
ELSE
--- Иначе берем просто домен без лишнего
REGEXP_EXTRACT(source, '^https?://((?:www\\.)?.*)')
END
AS new_source,
--- Определяем канал
CASE
WHEN REGEXP_CONTAINS(source, 'utm_medium.*') THEN REGEXP_EXTRACT(source, 'utm_medium=([\\w\\d-_%.]+)(?:&|$)')
WHEN REGEXP_CONTAINS(source, '^https?://(?:www\\.)?(yandex|google).*') THEN 'organic'
WHEN REGEXP_CONTAINS(source, '^https?://(?:www\\.)?(facebook|vk|instagram).*') THEN 'social'
WHEN source = '' THEN '(none)'
ELSE
REGEXP_EXTRACT(source, '^https?://((?:www\\.)?.*)')
END
AS medium,
FROM (
SELECT
'https://facebook.com' AS source
UNION ALL (
SELECT
'https://test.me/credo-vs-tredo?utm_source=ya_poisk_piter_bfl&utm_medium=lidgen&utm_campaign=text2&utm_content=image2' AS source )
UNION ALL (
SELECT
'https://test.me/credo-vs-tredo?utm_source=google&utm_medium=cpc&utm_campaign=text3&utm_content=image0' AS source)
UNION ALL (
SELECT
'https://test.me/credo-vs-tredo?utm_source=yandex&utm_medium=cpm&utm_campaign=text2&utm_content=image1'AS source)
UNION ALL (
SELECT
'https://google.com' AS source)
UNION ALL (
SELECT
'https://direct.yandex.ru' AS source)
UNION ALL (
SELECT
'https://www.yandex.ru' AS source )
UNION ALL (
SELECT
'https://link.2gis.ru'AS source)
UNION ALL (
SELECT
'https://vk.com' AS source)
UNION ALL (
SELECT
'' AS source)
UNION ALL (
SELECT
'https://instagram.com' AS source )) AS table_1