我必须处理几乎没有损坏的XML解码文件,而且我正在尝试以编程方式对其进行修复。
其中之一是,例如,我的开始标记的结束标记已损坏
因此,我需要删除单词之间的破折号(正则表达式中的 \ w ,因为它也可以包含数字),并用 <> 个字符
括起来我已经构建了此正则表达式
(?<=\w)-(?=\w)
但是它匹配 \ w 之间的每个破折号。我只需要匹配 <> 中包含的内容:
<text-numbers>
你能帮我吗? 预先非常感谢
安德里亚
答案 0 :(得分:0)
我建议
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,body{height: 100%;}
.parent {
width: 100vw ;
height: 100vh;
position: relative ;
background-color: black ;
z-index: 1 ;
}
.child {
width: 150px ;
height: 150px;
position: absolute ;
background-color: crimson ;
}
</style>
</head>
<body>
<div class="parent">
<div class="child"></div>
</div>
</body>
</html>
替换为yoururl.com/table/ELEMENT-ID
。参见regex demo。
详细信息
(\G(?!^)|</?)(\w*)-
-第1组(替换模式中的$1$2
):上一场比赛的结束,或者是(\G(?!^)|</?)
,其后还有一个可选的$1
(以防您在以<
作为分隔符的正则表达式文字中定义模式,将/
转换为/
)/
-第2组(替换模式为\/
):零个或多个单词字符(\w*)
-连字符。