在ibatis下匹配特殊手机号码(oracle数据库)

<isNotNull prepend="AND" property="endNumber">

            <isNotEmpty property="endNumber">

            	<isNotNull property="isRuleEndNumber">

            	<isNotEmpty property="isRuleEndNumber">

            		<isEqual property="isRuleEndNumber" compareValue="1">

		            	<isEqual property="endNumber" compareValue="-4">

					substr(t.UIM_CARD,11,1)!=4

				</isEqual>

				<isEqual property="endNumber" compareValue="AABAA">

					substr(t.UIM_CARD,11,1)=substr(t.UIM_CARD,10,1)

					and substr(t.UIM_CARD,8,1)=substr(t.UIM_CARD,7,1) 

					and substr(t.UIM_CARD,9,1)!=substr(t.UIM_CARD,10,1)

				</isEqual>

				<isEqual property="endNumber" compareValue="AAA">

					substr(t.UIM_CARD,10,1)=substr(t.UIM_CARD,9,1) 

					and substr(t.UIM_CARD,9,1)=substr(t.UIM_CARD,11,1)

					and substr(t.UIM_CARD,9,1)!=substr(t.UIM_CARD,8,1)

				</isEqual>

				<isEqual property="endNumber" compareValue="ABC">

					regexp_like(substr(t.UIM_CARD,9,3),'^(012|123|234|345|456|567|678|789)$$')

					and to_number(substr(t.UIM_CARD,8,1))+1!=to_number(substr(t.UIM_CARD,9,1))

				</isEqual>

				<isEqual property="endNumber" compareValue="AAAA">

					regexp_like(substr(t.UIM_CARD,8,4),'^([0-9])\1{3}$$')

				</isEqual>

				<isEqual property="endNumber" compareValue="ABCD">

					regexp_like(substr(t.UIM_CARD,8,4),'^(0123|1234|2345|3456|4567|5678|6789)$$')

				</isEqual>

				<isEqual property="endNumber" compareValue="AABB">

					substr(t.UIM_CARD,10,1)=substr(t.UIM_CARD,11,1)

					and substr(t.UIM_CARD,8,1)=substr(t.UIM_CARD,9,1)

					and substr(t.UIM_CARD,9,1)!=substr(t.UIM_CARD,10,1)

				</isEqual>

				<isEqual property="endNumber" compareValue="ABAB">

					substr(t.UIM_CARD,8,1)=substr(t.UIM_CARD,10,1)

					and substr(t.UIM_CARD,9,1)=substr(t.UIM_CARD,11,1)

					and to_number(substr(t.UIM_CARD,10,1))+1=substr(t.UIM_CARD,11,1)

				</isEqual>

				<isEqual property="endNumber" compareValue="88">

					substr(t.UIM_CARD,10,2)='88'

				</isEqual>

            		</isEqual>

            	</isNotEmpty>

            	</isNotNull>
		<isNotNull property="isRuleEndNumber">

             	 <isNotEmpty property="isRuleEndNumber">

              		<isEqual property="isRuleEndNumber" compareValue="0">

               			#endNumber#=substr(t.UIM_CARD,11-length(#endNumber#)+1,length(#endNumber#))

              		</isEqual>

             	 </isNotEmpty>

             	</isNotNull>
 上面分两部分,一部分按照规则匹配号码,下面部分按照尾数匹配号码.这些代码都是能正常使用的。
 
以下一些正则表达式来自网上,本人仔细研究测试过,能在JAVA代码里面使用,但是不能在SQL语句中使用:String s="5678";

  System.out.println(s.matches("^[0-9](?:(?<=0)1|(?<=1)2|(?<=2)3|(?<=3)4|(?<=4)5|(?<=5)6|(?<=6)7|(?<=7)8|(?<=8)9){3}$"));

  String s2="11";

  System.out.println(s2.matches("^([0-9])\\1$"));

  String pwd ="666";

  String regx = "^(\\d)\\1{2}$";以上都返回true String aabb="1122";

System.out.println(aabb.matches("^([0-9])\\1([0-9])\\2$"));

  

String abab="1212";

System.out.println(abab.matches("^([0-9](?:(?<=0)1|(?<=1)2|(?<=2)3|(?<=3)4|(?<=4)5|(?<=5)6|(?<=6)7|(?<=7)8|(?<=8)9){1})\\1$"));以上也都返回true String s="544354645435";

System.out.println(s.matches("^[^0-9]*$"));这个是false,呵呵。。
 
  
 
  

你可能感兴趣的:(oracle数据库)