2015-03-13 95 views

回答

0

我會分裂的 「:」 並使用11要素。

但是如果你必須使用正則表達式:

^(?:[^:]*:){10}:([^:]*) 

,並使用匹配的組1。

+0

謝謝波希米亞人。 – 2015-03-14 05:49:22

1

regexp_substr不關心捕獲組,因此不包含在匹配中的字符是不可能的。從最終計數會的工作,雖然:

-- Returns the substring after the 6th ':' from the end. 
select regexp_substr(id, '([^:]*:){5}[^:]*$') from tempnew 
-- If the string does not contain 5 ':', an empty string is returned. 

如果你需要從一開始就來算,你可以使用regexp_replace代替:

-- Returns the substring after the 11th ':' 
select regexp_replace(id, '^([^:]*:){11}') from tempnew 
-- If the string does not contain 11 ':', the whole string is returned. 
+0

感謝Markus Jarderot ......我工作過。 – 2015-03-13 13:31:20

0

您可以使用split_part爲了這個目的, 選擇split_part(ID ,':',12)from tempnew