c# - RegEx not being able to match data -
i using regex find , replace data. suppose code
dictionary<string, string> data=new dictionary<string, string>(); data.add("jid","421587"); string template ="your unique job number {jid} .your part collected us" string result = regex.replace(template, @"{([^{}]+)}", delegate(match match) { string key = match.groups[1].value; return data[key]; }); _body = result; return this;
actually trying find out character {jid}
, want replace {jid}
value store in dictionary guess patter used here @"{([^{}]+)}
not right find out data , replace {jid}
.
so please me how find {jid}
string , replace. thanks
edit
actually text trying replace huge html text , may why problem occur.
so manage whole thing way.
public mailtemplate parsetemplate(dictionary<string, string> data) { string template = getbody(); foreach(keyvaluepair<string, string> item in data) { if (item.key.toupper() != "attachedfilepath") { template = template.replace("{" + item.key + "}", item.value); } } _body = template; return this; }
Comments
Post a Comment