gpt4 book ai didi

java - java中使用正则表达式匹配多行文本

转载 作者:行者123 更新时间:2023-12-01 09:48:44 25 4
gpt4 key购买 nike

我的输入样本是:

<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 15">
<meta name=Originator content="Microsoft Word 15">
<link rel=File-List href="detailedFoot_files/filelist.xml">

我想做的是选择整个 html 标签并将其替换为某些内容。所以我使用正则表达式

<html.*>

如果我以 Mather.DOTALL 方式使用此正则表达式,则整个文本输入将被替换。

我不知道该怎么做。任何形式的帮助将不胜感激。

最佳答案

这个正则表达式似乎捕获了您正在寻找的内容。

pattern = "\<html[^>]*>?(.*)"

<强> Sample Here

关于java - java中使用正则表达式匹配多行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37770963/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com