例如 one > two > three > four > five
wordfour應該是結果字串。
我有這個運算式匹配所需的輸出:(?<=^(\w \s>\s){3})(\w )。
但它使用這個回傳空字串:
REGEXP_SUBSTR (t.column, '(?<=^(\w \s>\s){3})(\w )')。
這里有什么問題?
謝謝你。
注意:以“>”符號分隔的字串可以由兩個或多個單詞組成。例如:
one > two > three > four1 four2 > five應該回傳four1 four2
uj5u.com熱心網友回復:
如果它不必是正則運算式解決方案,請使用substr instr組合 ( result_1)。
或者,如果它必須是正則運算式,并且字串確實像您發布的那樣,則從中獲取第 4 個單詞( result_2)。
select trim(substr(col, instr(col, '>', 1, 3) 1,
instr(col, '>', 1, 4) - instr(col, '>', 1, 3) - 1
)) result_1,
--
regexp_substr(col, '\w ', 1, 4) result_2
from your_table;
uj5u.com熱心網友回復:
您需要將非消費模式轉換為消費模式,并使用其他引數來確保REGEXP_SUBSTR回傳正確的捕獲:
REGEXP_SUBSTR (t.column, '^([^>] \s >\s ){3}\s*([^>]*[^[:space:]>])', 1, 1, NULL, 2)
請注意,正則運算式中不再有后視,并且由于您需要 Group 2 值,因此最后一個引數設定為2.
查看
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/348221.html
