$str =1;$strx=2;$strd="a";
int a =10;
匹配所有 $xxx 就是前面的变量名字 不带$的不要

解决方案 »

  1.   

    大神们 我还想要 $xxx=xxx; 这个匹配啊
      

  2.   

    //\$[^= ]+
    var arr = '$str =1;$strx=2;$strd="a";'.match(/\$[^= ]+/ig);
    for(var v=0;v<arr.length;v++)
    {
    alert(arr[v]);
    }
    }
      

  3.   

    //正则表达式为:\$[a-zA-Z0-9="" ]+;//测试结果为
     string s = @"$str =1;$strx=2;$strd=""a"";int a =10;";
                Regex reg = new Regex(@"\$[a-zA-Z0-9="" ]+;");
               MatchCollection matchs =  reg.Matches(s);            foreach(Match m in matchs)
                {
                    Console.WriteLine(m.Value);
                }            Console.Read();