码迷,mamicode.com
首页 > 移动开发 > 详细

android 短信正则表达式错误

时间:2014-08-26 15:33:36      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:android   myanmar khmer   

前后都有中文的情况下如何正确提取URL
 
请帮忙做如下修改
mediatek\frameworks\base\op\java\com\mediatek\op\util\DefaultPatterns.java
public static Pattern getWebUrl(final String engIriChar, final String goodIriChar,
            final String topLevelDomainStrForWebUrlExpand) {
            return  Pattern.compile(
                    "((?:(http|https|Http|Https|rtsp|Rtsp):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\‘\\(\\)"
                    + "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
                    + "\\.\\+\\!\\*\\‘\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
                    + "((?:(?:[" + engIriChar + "][" + engIriChar + "\\-]{0,64}\\.)+"   // named host
                    + topLevelDomainStrForWebUrlExpand
                    + "|(?:(?:25[0-5]|2[0-4]" // or ip address
                    + "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(?:25[0-5]|2[0-4][0-9]"
                    + "|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1]"
                    + "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
                    + "|[1-9][0-9]|[0-9])))"
                    + "(?:\\:\\d{1,5})?)" // plus option port number
                    + "(\\/(?:(?:[" + goodIriChar + "\\;\\/\\?\\:\\@\\&\\=\\#\\~"  // plus option query params
                    + "\\-\\.\\+\\!\\*\\‘\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
                    + "(?:\\b|$)"); // and finally, a word boundary or end of
                                    // input.  This is to stop foo.sure from
                                    // matching as foo.su
    }

android 短信正则表达式错误

标签:android   myanmar khmer   

原文地址:http://blog.csdn.net/sergeycao/article/details/38847409

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!