REGEXP\u子类
到目前为止,正则表达式是我的弱点。 我正在尝试分解以下字符串REGEXP\u子类,regex,oracle,oracle10g,Regex,Oracle,Oracle10g,到目前为止,正则表达式是我的弱点。 我正在尝试分解以下字符串 Node 51 Path 1 Route 4 Node 51A Path 12 Route 3 Node 5 Path 12 Route 2 Node 7B Path 1 Route 1 我需要的是节点,节点的字母,路径和路线 提取节点的字母时遇到问题。节点的字母是单个非数字字符,始终紧跟在节点编号之后,不带空格 对于第2行和第4行 Node 51A Path 12 Route 3 - Nodes letter is A Node
Node 51 Path 1 Route 4
Node 51A Path 12 Route 3
Node 5 Path 12 Route 2
Node 7B Path 1 Route 1
我需要的是节点,节点的字母,路径和路线
提取节点的字母时遇到问题。节点的字母是单个非数字字符,始终紧跟在节点编号之后,不带空格
对于第2行和第4行
Node 51A Path 12 Route 3 - Nodes letter is A
Node 5 Path 12 Route 2 - Nodes letter is NULL
Node 7B Path 1 Route 1- Nodes letter is B
到目前为止,
with gen as (
select 'Node 51 Path 1 Route 4' x from dual union all
select 'Node 51A Path 12 Route 3' x from dual union all
select 'Node 5 Path 12 Route 2' x from dual union all
select 'Node 7B Path 1 Route 1' x from dual
)
select x ,
regexp_substr(x, '(\d+)',1,1) as Node ,
regexp_substr(x, '(\d+)',1,2) as Path ,
regexp_substr(x, '(\d+)',1,3) as Route
from gen
X NODE PATH ROUTE
------------------------ ------ ------ -------
Node 51 Path 1 Route 4 51 1 4
Node 51A Path 12 Route 3 51 12 3
Node 5 Path 12 Route 2 5 12 2
Node 7B Path 1 Route 1 7 1 1
Oracle 10gR2。因此您提取了整个节点并删除了所有数字。美好的谢谢
with gen as (
select 'Node 51 Path 1 Route 4' x from dual union all
select 'Node 51A Path 12 Route 3' x from dual union all
select 'Node 5 Path 12 Route 2' x from dual union all
select 'Node 7B Path 1 Route 1' x from dual
)
select x ,
regexp_substr(x, '\d+') as Node,
regexp_replace(regexp_substr(x, '\d+\S*'),'\d+') as NodeLetter ,
regexp_substr(x, '\d+',1,2) as Path ,
regexp_substr(x, '\d+',1,3) as Route
from gen