Sql 要得到后面的字符串。通过oracle中的正则表达式

Sql 要得到后面的字符串。通过oracle中的正则表达式,sql,regex,oracle,Sql,Regex,Oracle,我想在以后检索字符串。从具有如下值的表pos: Office.Secretary XYZ.Manager - Liaison ABC.Community Relations Officer 这应该转换为 Secretary Manager - Liaison Community Relations Officer 我用的是: SELECT REGEXP_REPLACE(REGEXP_SUBSTR (name, '..+' , 1), '.', '', 1, 1) FROM table_PO

我想在以后检索字符串。从具有如下值的表pos:

Office.Secretary
XYZ.Manager - Liaison
ABC.Community Relations Officer
这应该转换为

Secretary
Manager - Liaison
Community Relations Officer
我用的是:

 SELECT REGEXP_REPLACE(REGEXP_SUBSTR (name, '..+' , 1), '.', '', 1, 1) FROM table_POS;
但是我得到了列的详细信息。

您可以使用(它将在上次
之后删除)

如果要在第一次
之后删除,可以使用

SELECT REGEXP_REPLACE(name, '^.*?\.' , '') FROM table_POS;

如果需要从开始到第一个点删除字符串块,则需要使用求反字符类正则表达式解决方案:

SELECT REGEXP_REPLACE(name, '^[^.]+[.]', '') FROM table_POS;
注意这里

  • ^
    -匹配字符串的开头
  • [^.]+
    -匹配除文字点以外的一个或多个字符
  • [.]
    -匹配文字点
整个匹配的子字符串被替换为空字符串,因此被删除


如果您需要删除一块字符串直到最后一个点,您需要rock的解决方案,类似于从表中选择REGEXP_REPLACE(名称“^.+[.]”,“”

   select regexp_replace('ABC.Community Relations Officer','([^\.]{0,}\.)(.*)','\2') from dual;
尝试regexp组捕获

1-st组([^\.]{0,}\)
-将所有内容与第一个点进行匹配

2组(.*)
-匹配点后的所有内容

“\2”
-将整个字符串替换为第二组中的值

例如,有了这个未来,您可以更改组的顺序

select regexp_replace('ABC.Community Relations Officer','([^\.]{0,}\.)(.*)','\2  -- \1') from dual;

尝试从表中选择REGEXP_REPLACE(名称“^[^.]+[.].”,”谢谢!这奏效了。。
select regexp_replace('ABC.Community Relations Officer','([^\.]{0,}\.)(.*)','\2  -- \1') from dual;