C# 使用正则表达式提取文本
我有一个字符串变量,它包含C# 使用正则表达式提取文本,c#,regex,C#,Regex,我有一个字符串变量,它包含 "A regular expression is an object that describes a pattern of characters. <strong>Regular expressions are used to perform pattern-matching.</strong> and "search-and-replace" functions on text. “正则表达式是描述字符模式的对象。 正则表达式用于执行模
"A regular expression is an object that describes a pattern of characters.
<strong>Regular expressions are used to perform pattern-matching.</strong> and "search-and-replace" functions on text.
“正则表达式是描述字符模式的对象。
正则表达式用于执行模式匹配。和文本上的“搜索和替换”功能。
我必须提取
"<strong>Regular expressions are used to perform pattern-matching</strong>"
“正则表达式用于执行模式匹配”
为此,我正在使用
^<strong>([A-Za-z0-9-\s]+)</strong>$
^([A-Za-z0-9-\s]+)$
正则表达式。
但它不起作用。
知道为什么吗?试试这个
<strong>([^<]*)</strong>
([^如果试图匹配,则结束标记前的点不匹配正则表达式用于执行模式匹配。
<strong>([A-Za-z0-9-\s.]+)</strong>