[英]Replace html entity if within curly braces
I have this string below. 我下面有这个字符串。 I can capture each curly brace with
(\\{\\{.*?\\}\\})/igm
but I need a way of replacing any instance of '
我可以用
(\\{\\{.*?\\}\\})/igm
捕获每个大括号,但是我需要一种替换'
任何实例的方法'
with "
in the below string, with javascript. 与
"
在下面的字符串,使用javascript。
{% layout none %}<html data-reactid=".1h8va4op8n4" data-react-checksum="-832592417">
<head lang="en" data-reactid=".1h8va4op8n4.0">
<meta charset="UTF-8" data-reactid=".1h8va4op8n4.0.0">
<title data-reactid=".1h8va4op8n4.0.1"></title>
<link rel="stylesheet" href="{{ 'main.css' | asset_file }}" data-reactid=".1h8va4op8n4.0.2">
</head>
<body data-reactid=".1h8va4op8n4.1">
<div id="main" data-reactid=".1h8va4op8n4.1.0"></div>
<script type="text/javascript" src="{{ 'bundle.js' | asset_file }}" data-reactid=".1h8va4op8n4.1.1"></script>
</body>
</html>
You could do this using a callback function. 您可以使用回调函数执行此操作。
var r = s.replace(/{{[^}]*}}/g, function(v) {
return v.replace(/'/g, '"');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.