使用Groovy或Java删除线路高度的正则罚款



我想创建一个正则表达式以删除样式的线条高度,可以是以下标准:

<p align="justify" style="margin-bottom: 0cm; font-weight: normal; line-height: 100%; text-decoration: none">

或那个:

<p align="justify" style="margin-bottom: 0cm; font-weight: normal; line-height: 100%">

该属性可以以"或;可能具有任何值结尾。

const removeLineHeightTag = (text: string) => {
  const regex = /(line-height: ((d).)*(;)*)/g;
  try {
    return `${text.replace(regex, '')}`;
  } catch (e) {
    return text;
  }
};
let yourText = '...' // change to your text
yourText = removeLineHeightTag(yourText)

使用此正则表达式:(line-height:[ds]+%;?)。要替换它,请执行以下操作。

yourString.replaceAll("(line-height:[\d\s]+%;?)", "");  

最新更新