111,092
社区成员




static void Main(string[] args)
{
const string sEscape = "#,.#";
string sample = @"$aaa$bbbb$要的内容$汉字$\$转义也要\$$eeee$@……*$";
string s = sample.Replace(@"\$", sEscape);
Console.WriteLine(s);
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(
@"\$(?<a>[^\$]+?)\$",
System.Text.RegularExpressions.RegexOptions.Singleline);
System.Text.RegularExpressions.MatchCollection mc = reg.Matches(s);
foreach (System.Text.RegularExpressions.Match m in mc)
Console.WriteLine(m.Groups["a"].Value.Replace(sEscape, @"\$"));
Console.ReadKey();
}
(?<k1>[\\\$]++)([\s\S]*?)\k<k1>
var txt = @"$aaa$bbbb$要的内容$汉字$\$转义也要\$$eeee$@……*$";
foreach (System.Text.RegularExpressions.Match match
in System.Text.RegularExpressions.Regex.Matches(txt, @"(?<k1>[\\\$]+)([^\\\$]*)\k<k1>"))
{
Console.WriteLine(match.Groups[1].Value);
}
var str = "$aaa$bbbb$要的内容$汉字$\\$转义也要\\$$eeee$@……*$";
var arr = [];
str.replace(/\$((\\\$|.)+?)\$/g,function(s,a){
arr.push(a);
});
alert(arr);