Cor*_*rei 1 c# pattern-matching
如何使用该String.Replace功能使用模式?
我想做什么:
newTextBox = newTextBox.Replace("<Value> #'a string of any number of chars#' </Value>",
"<Value>" + textBoxName + "</Value>");
Run Code Online (Sandbox Code Playgroud)
#'任意数量的字符串#'可以是任何字符串.
使用正则表达式:
newTextBox.Text =
Regex.Replace(
newTextBox.Text,
@"<Value>[^\<]+</Value>",
"<Value>" + textBoxName.Text + "</Value>");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5447 次 |
| 最近记录: |