zoukankan      html  css  js  c++  java
  • test java String.matches again

    i found the String.matches must match the whole string,could not match part of string

    http://stackoverflow.com/questions/4771447/java-string-matches-regex-with-or-pipe

    this is a trap

    package ZZZZ;

    import java.util.regex.PatternSyntaxException;

    public class cc {


        public static void main(String[] args) {
           
            String subjectString="我__";
            // TODO Auto-generated method stub
            try {
                String regex="[^a-zA-Z0-9]*$";
               
                boolean foundMatch = subjectString.matches(regex);
                System.out.println(foundMatch);
            } catch (PatternSyntaxException ex) {
                // Syntax error in the regular expression
                System.out.println(ex.toString());
            }

        }

    }

  • 相关阅读:
    一些$LCT$的瓜皮题目
    写点东西(关于背包问题)
    字符串算法总结
    常系数齐次线性递推
    原根算法与剩余定理
    问题集
    常用链接
    回形针PaperClip
    6.824拾遗
    杂项
  • 原文地址:https://www.cnblogs.com/lexus/p/2378995.html
Copyright © 2011-2022 走看看