【发布时间】:2019-04-01 11:21:09
【问题描述】:
我有一个包含//script[@data-type="application/ld+json"]的页面
此脚本的内容与以下类似。
<script>
{
"one": "some text here",
"two": "some "other" text here"
}
</script>
是否可以使用正则表达式将双引号替换为单引号,所以我有:
"two": "some 'other' text here"
或者完全删除内引号
我可以使用replace函数
主要问题是我不知道如何只匹配字符串中的引号。
【问题讨论】:
-
使用像 Perl 这样的特色引擎会很困难,更不用说使用
replace()函数了,相比之下,它使用的语法非常有限。所以不,这是不可能的。