.net 匹配所有标点符号 java 匹配所有标点符号

    static void Main(string[] args)
        {
            Regex regex=new Regex("\\p{P}");
            String str = " ;。、,!\"#$%&'*+,-./:;<=>?@[\\]^_`{|}~";
            MatchCollection mc=regex.Matches(str);
            if (mc != null && mc.Count != 0) 
            {
                foreach (Match m in mc)
                {
                    Console.Write(m.Value);
                }
            }
            Console.ReadLine();
        }

    public static void main(String[] args) {
            
            Pattern pattern=Pattern.compile("\\pP");
            Matcher match=pattern.matcher(" ;。、,!\"#$%&'*+,-./:;<=>?@[\\]^_`{|}~");
            while(match.find()){
                String p=match.group();
                System.out.print(p);
            }
    }

;。、,!"#%&'*,-./:;?@[\]_{}

posted on 2012-08-02 17:22  雨渐渐  阅读(365)  评论(0编辑  收藏  举报

导航