我需要一个检查DebugData的正则表达式,如果它有除字母[a-zA-Z]以外的任何数字或特殊字符,请用空格替换这些特殊字符。这些表存在于Google Big Query中,我正在使用IPython笔记本查询它。
示例:当DebugData为Movist2时,则ActualCarrier应为Movist,当DebugData为LAO GS2时,ActualCarrier应为LAOGS2,当DebugData为CLARO" 3时,则ActualCarrier为CLARO。
SELECT
Id, e.Carrier as AssignedCarrier,
CASE
WHEN lower(DebugData) LIKE 'jasp%' THEN 'Jasper'
WHEN lower(DebugData) LIKE 'telu%' THEN 'Telus'
WHEN REGEXP_MATCH(DebugData,'\\w+\\d+') THEN DebugData
WHEN REGEXP_MATCH(lower(DebugData),'\\d+') THEN c.Network
END
AS ActualCarrier
FROM debug_table
这是我补充的声明:
ELSE REGEXP_REPLACE(lower(DebugData),'\\[^a-zA-Z]',' ')
我仍然得到这个输出:
HardwareId DebugData ActualCarrier count
550466188 CLARO"3 None 5
答案 0 :(得分:2)
看起来像:
var hpDim = function() {
var qNondArray = qNond();
var mySpline = new MonotonicCubicSpline(
qNondArray, [16.60, 16.60, 16.52, 16.34, 16.17, 15.91, 15.47, 15.12, 14.77, 14.33, 13.90, 13.46]);
var total = mySpline.interpolate(qdim());
$('#hpDim').val(+total.toFixed(2));
return total;
};
hpDim();
https://cloud.google.com/bigquery/query-reference#advanced-examples_12
答案 1 :(得分:1)
尝试
SELECT
DebugData,
REGEXP_REPLACE(DebugData, r'[^a-zA-Z]', ' ') as ActualCarrier
FROM
(SELECT'Movist2' as DebugData),
(SELECT'LAO GS2' as DebugData),
(SELECT'CLARO"3' as DebugData)
已添加以解决其他评论/问题
SELECT
DebugData,
CASE
WHEN REGEXP_MATCH(LOWER(DebugData),r'^\d+$') THEN Network
ELSE REGEXP_REPLACE(LOWER(DebugData),r'[^a-zA-Z]', ' ')
END AS ActualCarrier
FROM
(SELECT'123' AS DebugData, 'aaa' AS Network),
(SELECT'Movist2' AS DebugData, 'bbb' AS Network),
(SELECT'456' AS DebugData, 'ccc' AS Network),
(SELECT'LAO GS2' AS DebugData, 'ddd' AS Network),
(SELECT'CLARO"3' AS DebugData, 'eee' AS Network),
(SELECT'Test' AS DebugData, 'fff' AS Network)