1、/^表示在开始位置
2、^[abc]不包括a或b或c
你的是第一个的用法。

解决方案 »

  1.   

    我是要试第一个用法。
    可怎么用啊,我试了"^hell"、"/^hell"、"/^hell/",hellaaa都不能匹配。
      

  2.   

    测试了一下
    ----------------------------------------------------------------------------------
    在网上看到一些文章,说
    /^hell/
      因为上述正则表达式中包含“^”定位符,所以可以与目标对象中以 “hell”, “hello”或 “hellhound”开头的字符串相匹配。
    ----------------------------------------------------------------------------------在javascript中是正确的。在java中则不正确,需要这样写:import java.util.regex.*;class  TestRegEx
    {
    public static void main(String[] args) 
    {
    Pattern p=Pattern.compile("^hell.*");
    Matcher m=p.matcher("hell");
    System.out.println(m.matches());
    }
    }具体原因还不清楚,有空再去查查sun的文档。