简体   繁体   English

需要正则表达式模式

[英]Regex pattern needed

If have below text: 如果有以下文字:

<script>

  LMS.pageData['product']['percentageDiscount'] ='26';
  LMS.pageData['product']['newPrice'] ='37';
  LMS.pageData['product']['oldPrice'] ='50.0';
  LMS.pageData['product']['savedAmount'] ='13';
  LMS.pageData['product']['price']['value'] = '37';

</script>

Then I need to capture newPrice and oldPrice values, please help me for Regex pattern. 然后,我需要捕获newPrice和oldPrice值,请为正则表达式模式提供帮助。

thanks! 谢谢!

You can use the following to match: 您可以使用以下内容进行匹配:

\['newPrice'\] ='([\d.]*)'|\['oldPrice'\] ='([\d.]*)'|\['price'\]\['value'\] = '([\d.]*)'

And extract $1 as newPrice , $2 as oldPrice and $3 as value . 并提取$1作为newPrice$2作为oldPrice$3作为value

See DEMO 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM