代码改变世界

正则表达式实现字符串换位吗

2011-05-11 11:03  Tracy.  阅读(710)  评论(1)    收藏  举报

能用正则表达式实现字符串换位吗

John, Smith 变成 Smith John

 

Solution:

SQL> select regexp_replace('John, Smith','^([^,*]{1,}),([^,*]{1,})','\2 \1') from dual;
REGEXP_REPLACE('JOHN,SMITH','^
------------------------------
Smith John