Regex pattern needed

孤者浪人 提交于 2019-12-20 07:58:43

问题


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.

thanks!


回答1:


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.

See DEMO



来源:https://stackoverflow.com/questions/30554938/regex-pattern-needed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!