我有以下数据
notificationBuilder.setSmallIcon()
使用oracle regexpr的预期输出
1241 - ASGEF - AFZHE
1242 - ASGEF1
1243 - UJHAHAHG - AGHBNG
答案 0 :(得分:1)
SUBSTR + INSTR
可能会运行得更快(即不需要正则表达式)。 result
显示,而result_2
显示一个正则表达式选项。
SQL> with test (col) as
2 (select '1241 - ASGEF - AFZHE' from dual union all
3 select '1242 - ASGEF1' from dual union all
4 select '1243 - UJHAHAHG - AGHBNG' from dual
5 )
6 select col,
7 trim(substr(col, instr(col, '-') + 1)) result,
8 ltrim(regexp_substr(col, '-.+'), '- ') result_2
9 from test;
COL RESULT RESULT_2
------------------------ ------------------------ ------------------------
1241 - ASGEF - AFZHE ASGEF - AFZHE ASGEF - AFZHE
1242 - ASGEF1 ASGEF1 ASGEF1
1243 - UJHAHAHG - AGHBNG UJHAHAHG - AGHBNG UJHAHAHG - AGHBNG
SQL>