日期:2014-05-19  浏览次数:20405 次

正则表达式替换的问题
asdfadsfasdf[vacancy:len=100],
[vacancy:len=100]是dfadfaf,
dsfasfdsf[vacancy:len=100]fadafasdfasdf[vacancy:len=300]

把上面这个字符串里面的所有[vacancy:len=100]换成 <input   type= 'text '   style= 'width:100px '   /> 如果是300的话,width就是300px了。


------解决方案--------------------
try

string yourStr = ...............;
string resultStr = Regex.Replace(yourStr, @ "\[vacancy:len=(\d+)\] ", @ " <input type= 'text ' style= 'width:$1px ' /> ", RegexOptions.IgnoreCase);