日期:2014-05-18  浏览次数:20469 次

求一正则表达式,有点难度(20分)
werwerwe <?内容?> dgdgdfg
sdfsdfsdf
dsdfsdf
sdfsdfsdf <?内容?>
sdsfdsdf '
sdfsdfsd
===========================================
替换后:
<?内容?> <?内容?>

------解决方案--------------------
难吗

string str = @ "werwerwe <?内容?> dgdgdfg
sdfsdfsdf
dsdfsdf
sdfsdfsdf <?内容?>
sdsfdsdf '
sdfsdfsd ";
str = Regex.Replace(str, "^[^ <> ]*(?= <)|(? <=> )[^ <> ]*(?= <)|(? <=> )[^ <> ]*$|^[^ <> ]*$ ", " ");