I'm reading html source code and I need to get below data from it.
LMS.pageData['product']['maxThreshold'] ='6';
in above example I need to catch 6.
You can use a simple capture grouping :
"LMS.pageData\['product'\]\['maxThreshold'\] ='(\d)';"
then you need to extract the 1st group from matched pattern!
You can also use look-around that returns the number directly without need to get the first group :
"(?<=LMS.pageData\['product'\]\['maxThreshold'\] =')\d(?=';)"
You can use the look-arounds to get a number inside '...' at the end of the line, like this:
<?php
$re = "#(?<=')\d+(?=';\s*$)#m";
$str = "LMS.pageData['product']['maxThreshold'] ='6';";
preg_match($re, $str, $matches);
print_r($matches[0]);
See IDEONE demo
Use preg_match_all to obtain multiple matches if input contains multiple lines with '6';s.