This question already has an answer here:
(这个问题已经在这里有了答案:)
I need to replace the wte_embed_trips_width = "100%"
in the following string.
(我需要在以下字符串中替换wte_embed_trips_width = "100%"
。)
<script type="text/javascript">
var wte_embed_trips_width = "100%";
var wte_embed_trips_height = "500px";
var wte_embed_trips_param = "ids";
var wte_trp_embed_id = "1526";
var wte_embed_source_site = "http://wp-travel-engine.test/";
var wte_embed_type = "wte_trips_embedder_trips";
var wte_embed_ids_string = "543,547,532";
var wte_embed_layout = "grid";
var wte_embed_posts_num = "false";
</script>
<script src="http://wp-travel-engine.test/wp-content/plugins/wte-trips-embedder/assets/js/wpte-embed-handler.js" type="text/javascript"></script>
<div style="--aspect-ratio: 16/9;" id="wte-trips-embedder-1526"></div>
I am using /wte_embed_trips_width = "\d+(%{1}|(px){1})"/gmui
regular expression works perfectly in regex101.com but when I use it in acutal, it doesn't work.
(我正在使用/wte_embed_trips_width = "\d+(%{1}|(px){1})"/gmui
正则表达式在regex101.com中可以正常使用,但是当我在acutal中使用它时,它将无法正常工作。)
var regexp = new RegExp('wte_embed_trips_width = "d+(%{1}|(px){1})"', 'gmui');
var a = `<script type="text/javascript">var wte_embed_trips_width = "100%"; var wte_embed_trips_height = "500px"; var wte_embed_trips_param = "ids"; var wte_trp_embed_id = "1526"; var wte_embed_source_site = "http://wp-travel-engine.test/"; var wte_embed_type = "wte_trips_embedder_trips"; var wte_embed_ids_string = "543,547,532"; var wte_embed_layout = "grid"; var wte_embed_posts_num = "false";</script><script src="http://wp-travel-engine.test/wp-content/plugins/wte-trips-embedder/assets/js/wpte-embed-handler.js" type="text/javascript"></script><div style="--aspect-ratio: 16/9;" id="wte-trips-embedder-1526"></div>`;
regexp.test(a); // returns false. shoud have return true according regex101.com
The link to regex is https://regex101.com/r/L67WX4/2/
(到正则表达式的链接是https://regex101.com/r/L67WX4/2/)
ask by Sagar Bahadur Tamang translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…