Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在标记前查找文本_Jquery_Regex_Replace_Find - Fatal编程技术网

Jquery 在标记前查找文本

Jquery 在标记前查找文本,jquery,regex,replace,find,Jquery,Regex,Replace,Find,我在下面的XML文件链接中有一个文本 <p>The artificial and industrial uses <xref>1989</xref> of microorganisms for material production have a long history of more than a thousand years. Recently, genetic operations have been widely applied to improve

我在下面的XML文件链接中有一个文本

<p>The artificial and industrial uses <xref>1989</xref> of microorganisms for material production have a long history of more than a thousand years. Recently, genetic operations have been widely applied to improve production. Two generally considered <xref>approaches, 2017</xref> introduce enzymes that have higher activities from other organisms or species and introduce enzymes to realize metabolic pathways that do not naturally occur in the microorganisms. The former method is popular because its operation is simpler and improvements are more predictable than <xref>(2001)</xref> with the latter method. <xref>2013</xref> Conventional gene modifications using ultraviolet or other radiation types are easy to achieve and have been widely applied in many industries. Nevertheless, the efficiency of such improvements is quite low because gene modifications occur accidentally and uncontrollably, and progress is made serendipitously. Therefore, gene introduction is currently used along with conventional methods.</p>
输出类

<p>The artificial and industrial <u>uses <xref>1989</xref></u> of microorganisms for material production have a long history of more than a thousand years. Recently, genetic operations have been widely applied to improve production. Two generally <u>considered <xref>approaches, 2017</xref></u> introduce enzymes that have higher activities from other organisms or species and introduce enzymes to realize metabolic pathways that do not naturally occur in the microorganisms. The former method is popular because its operation is simpler and improvements are more predictable <u>than <xref>(2001)</xref></u> with the latter <u>method. <xref>2013</xref></u> Conventional gene modifications using ultraviolet or other radiation types are easy to achieve and have been widely applied in many industries. Nevertheless, the efficiency of such improvements is quite low because gene modifications occur accidentally and uncontrollably, and progress is made serendipitously. Therefore, gene introduction is currently used along with conventional methods.</p>

我在元素之前浏览并查找文本,但我并没有得到解决方案。请提前提出解决方案,谢谢

您不应该使用正则表达式解析html,因为html可能具有嵌套结构,从而导致意外行为

但正如我在你的例子中看到的,它是简单的非嵌套的,所以你可以使用这个正则表达式

([\w.]+\s+(?:<xref>.*?<\/xref>))

您应该避免使用正则表达式解析html。@Swashi:您可以编辑您的帖子并添加一些您想要匹配的示例和一些您不想要匹配的示例吗?如果您使用Skype,您可以搜索并添加我的id pkr555。我们可以在那里谈是的已经给你回电话了
([\w.]+\s+(?:<xref>.*?<\/xref>))
<u>\1</u>