我有一个字符串变量,它包含
"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>$正则表达式。但它不起作用。知道为什么吗?
发布于 2012-02-07 17:07:00
尝尝这个
<strong>([^<]*)</strong>或者这个
<strong>([A-Za-z0-9-\s.]+)</strong>由于以下原因,您的表达式不起作用:
<strong>之前和</strong>之后都没有任何内容时,模式才会匹配。在您的例子中,在字符类表达式中,</strong>发布于 2012-02-07 17:08:51
如果尝试匹配<strong>Regular expressions are used to perform pattern-matching.</strong>,则不匹配结束标记之前的点
https://stackoverflow.com/questions/9173487
复制相似问题