方法1:
Select translate('254名字性别介绍','1234567890名字性别介绍’','1234567890') From dual
方法2:
看俺的java实现
首先:
create or replace and compile java source named stringutil as
import Java.io.*;
import Java.sql.*;
public class StringUtil
{
public static String filterStr2Num(String str){
String tmpstr = str;
String savestr;
String result = "";
for (int i=0;i
savestr = tmpstr.substring(i,i+1);
if (StringUtil.isNumeric(savestr)){
result+=savestr;
}
}
return result;
}
public static boolean isNumeric(String str){
try{
Integer.valueOf(str);
return true;
}catch(Exception e){
return false;
}
}
}
然后:
create or replace function Java_filterStr2Num(str In Varchar) return varchar2 as
LANGUAGE JAVA
NAME 'StringUtil.filterStr2Num(java.lang.String) return java.lang.String';
再然后,无敌啦~~~
Select java_filterStr2Num('254名字性345345别介绍') From dual;
阅读(2386) | 评论(0) | 转发(0) |