gpt4 book ai didi

javascript - REGEX 前瞻问题

转载 作者:行者123 更新时间:2023-11-28 08:24:02 24 4
gpt4 key购买 nike

我需要从 html 文件中检索税额,但 JavaScript 似乎不支持前瞻。这是我需要找到的代码和字符串。

HTML 片段

<td align="right" valign="top"><span style="font-family:verdana,arial; font-size:12px; color:#000000;"><b>Tax:</b></span></td>
<td align="right" valign="top"><span style="font-family:verdana,arial; font-size:12px; color:#000000;"><b>$30.10</b></span></td>

正则表达式字符串

(?<=(Tax:.*\n.*))(=?\$\d*.\d{2})

我收到语法错误,量词无效。有没有更简单的方法来做到这一点?

最佳答案

您不需要为此进行前瞻或后瞻。尝试匹配此模式:

税:[\s\S]*?(\$\d*\.\d{2})

然后替换为$1

关于javascript - REGEX 前瞻问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22641622/

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