我有一个 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="name">word1</string>
<string name="namee">word2</string>
<string name="nameee">word3</string>
</resources>
我想找到> <之间的每个单词。因此 word1、word2 和 word3。我已经写了一些代码,但是那个正则表达式只能找到第一个单词(word1)。
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamReader sr = new StreamReader(openFileDialog1.FileName);
string s = sr.ReadToEnd();
richTextBox1.Text = s;
}
string txt = richTextBox1.Text;
string foundWords = Regex.Match(txt, @"\>(\w+)\<").Groups[1].Value;
richTextBox1.Text = foundWords;
}
我想找到 > < 之间的每个单词并将其显示在富文本框中。