我在其他字符串中替换字符串 [英] i have replace string in other string
本文介绍了我在其他字符串中替换字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
示例: - 我的姓名是(xyz)我的否(11111111111)
此字符串中的
(xyz)和(11111111111)在输入时替换为{variable}
这个字符串在文本框中然后替换并复制到另一个文本框
INPUT: - textbox1 =我的名字是(xyz)我的号码(11111111111)
输出:-textbox2 =我的名字是{variable}我的No {variable}
解决方案
你可以使用 Regex.Replace [ ^ ]
string inputText = textbox1.Text; // 我的名字是(xyz)我的号码(11111111111);
textbox2。 Text = Regex.Replace(inputText, @ (\(。*?\)) , {variable}); // 我的名字是{variable} My No {variable}
example:- My Name Is (xyz) My No (11111111111)
in this string (xyz)and(11111111111) replace to {variable}
when enter this string in textbox then replace and copy to another textbox
INPUT :- textbox1=My Name Is (xyz) My No (11111111111)
OUTPUT:-textbox2=My Name Is {variable} My No {variable}
解决方案
you can use Regex.Replace[^]
string inputText= textbox1.Text; //"My Name Is (xyz) My No (11111111111)"; textbox2.Text =Regex.Replace(inputText, @"(\(.*?\))","{variable}"); //My Name Is {variable} My No {variable}
这篇关于我在其他字符串中替换字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文