求简单正则
$str =1;$strx=2;$strd="a";int a =10;
匹配所有 $xxx 就是前面的变量名字 不带$的不要 --------------------编程问答-------------------- --------------------编程问答-------------------- \b(\$\w*)\b --------------------编程问答-------------------- string pattern=@"\$\w+"; --------------------编程问答-------------------- --------------------编程问答-------------------- (?i)\$\w+\b --------------------编程问答-------------------- \$\w+\b --------------------编程问答-------------------- 大神们 我还想要 $xxx=xxx; 这个匹配啊 --------------------编程问答-------------------- --------------------编程问答-------------------- (\$[\w\s]*=[\w"]*) --------------------编程问答-------------------- \$\w+\b\s*=[^;]+; --------------------编程问答--------------------
--------------------编程问答-------------------- //正则表达式为:\$[a-zA-Z0-9="" ]+;
//\$[^= ]+
var arr = '$str =1;$strx=2;$strd="a";'.match(/\$[^= ]+/ig);
for(var v=0;v<arr.length;v++)
{
alert(arr[v]);
}
}
//测试结果为
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(); --------------------编程问答-------------------- 用10楼的吧
补充:.NET技术 , C#