REGEXP_REPLACE URL 大查询
REGEXP_REPLACE URL BIGQUERY
我有两种需要清洁的 URL,它们看起来像这样:
["//xxx.com/se/something?SE_{ifmobile:MB}{ifnotmobile:DT}_A_B_C_D_E_F_G_H"]
["//www.xxx.com/se/car?p_color_car=White?SE_{ifmobile:MB}{ifnotmobile:DT}_A_B_C_D_E_F_G_H"]
我想要的结果是;
SE_{ifmobile:MB}{ifnotmobile:DT}_A_B_C_D_E_F_G_H"
我想删除括号和 SE 之前的所有内容,URLS 不同所以我想删除:
第一个URL
["//xxx.com/se/something?
第二个URL:
["//www.xxx.com/se/car?p_color_car=White?
我无法理解它,我试过这个 .*\/
。
但它仍然会保留我不想要的字符串,例如:
(1 url) =
something?
(2 url) car?p_color_car=White?
您可以使用
regexp_replace(FinalUrls, r'.*\?|"\]$', '')
详情
.*\?
- 除换行符外的任何零个或多个字符,尽可能多,然后 ?
char
|
- 或
"\]$
- 字符串末尾的 "]
子字符串。
注意 regexp_replace
语法,不能省略替换参数,参见 reference:
REGEXP_REPLACE(value, regexp, replacement)
Returns a STRING
where all substrings of value
that match regular
expression regexp
are replaced with replacement
.
You can use backslashed-escaped digits ( to ) within the
replacement
argument to insert text matching the corresponding
parenthesized group in the regexp
pattern. Use [=24=] to refer to the
entire matching text.
我有两种需要清洁的 URL,它们看起来像这样:
["//xxx.com/se/something?SE_{ifmobile:MB}{ifnotmobile:DT}_A_B_C_D_E_F_G_H"]
["//www.xxx.com/se/car?p_color_car=White?SE_{ifmobile:MB}{ifnotmobile:DT}_A_B_C_D_E_F_G_H"]
我想要的结果是;
SE_{ifmobile:MB}{ifnotmobile:DT}_A_B_C_D_E_F_G_H"
我想删除括号和 SE 之前的所有内容,URLS 不同所以我想删除:
第一个URL
["//xxx.com/se/something?
第二个URL:
["//www.xxx.com/se/car?p_color_car=White?
我无法理解它,我试过这个 .*\/
。
但它仍然会保留我不想要的字符串,例如:
(1 url) =
something?
(2 url) car?p_color_car=White?
您可以使用
regexp_replace(FinalUrls, r'.*\?|"\]$', '')
详情
.*\?
- 除换行符外的任何零个或多个字符,尽可能多,然后?
char|
- 或"\]$
- 字符串末尾的"]
子字符串。
注意 regexp_replace
语法,不能省略替换参数,参见 reference:
REGEXP_REPLACE(value, regexp, replacement)
Returns a
STRING
where all substrings ofvalue
that match regular expressionregexp
are replaced withreplacement
.You can use backslashed-escaped digits ( to ) within the
replacement
argument to insert text matching the corresponding parenthesized group in theregexp
pattern. Use [=24=] to refer to the entire matching text.