正则表达式拆分问题

[复制链接]
查看11 | 回复9 | 2007-10-20 08:38:44 | 显示全部楼层 |阅读模式
如何把 “一次性空针(2ml~2.5ml)”和
复方苦参(5ml*5)
里面的拆分出来形成新的两列
一次性空针(2ml~2.5ml)”----一次性空针()”----2ml~2.5ml
复方苦参(5ml*5)-------------------复方苦参()-----------5ml*5
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
SQL> SELECT * FROM TEST;
NAME
--------------------
复方苦参(5ml*5)
SQL>
select substrb(name,1,instrb(name,'('))||')' name1,
regexp_replace(name,'^.*\((.*)\)$','\1') name2
from test
NAME1 NAME2
------------------------
复方苦参()5ml*5
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
学习了,请问ls的,你解答 过滤出中文的帖子,能否给个链接??
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
最初由 eyes0000 发布
[B]如何把 “一次性空针(2ml~2.5ml)”和
复方苦参(5ml*5)
里面的拆分出来形成新的两列
一次性空针(2ml~2.5ml)”----一次性空针()”----2ml~2.5ml
复方苦参(5ml*5)-------------------复方苦参()-----------5ml*5 [/B]

可不用正则表达式
[PHP]
SQL> select substrb(name,1,instrb(name,'('))||')' name1,
2 rtrim(substrb(name,instrb(name,'(')+1),')') name2
3from test;
NAME1
NAME2
--------------------- --------------------
复方苦参()
5ml*5
SQL>
.
[/PHP]
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
最初由 hanjs 发布
[B]学习了,请问ls的,你解答 过滤出中文的帖子,能否给个链接?? [/B]

http://www.itpub.net/showthread.php?s=&threadid=847680
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
REGEXP_REPLACE无效?????????
SQL> select regexp_replace('复方苦参8888','^.*\((.*)\)$','\1') name2
2from dual
3/

select regexp_replace('复方苦参(5ml*5)','^.*\((.*)\)$','\1') name2
from dual

ORA-00904: "REGEXP_REPLACE": 无效的标识符
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
最初由 tybh 发布
[B]REGEXP_REPLACE无效?????????
SQL> select regexp_replace('复方苦参8888','^.*\((.*)\)$','\1') name2
2from dual
3/

select regexp_replace('复方苦参(5ml*5)','^.*\((.*)\)$','\1') name2
from dual

ORA-00904: "REGEXP_REPLACE": 无效的标识符 [/B]

oracle 10G以上版本
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
最初由 atgc 发布
[B]
可不用正则表达式
[PHP]
SQL> select substrb(name,1,instrb(name,'('))||')' name1,
2 rtrim(substrb(name,instrb(name,'(')+1),')') name2
3from test;
NAME1
NAME2
--------------------- --------------------
复方苦参()
5ml*5
SQL>
.
[/PHP] [/B]

一定要区分汉字状态下的(和英文输入下的(
good luck!
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
最初由 atgc 发布
[B]
http://www.itpub.net/showthread.php?s=&threadid=847680 [/B]

多谢了!
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
学习了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行