php - regex inside tags with specified string -
i'm not @ regex have string :
 $str = '<span id="mainstatusspan" style="background: brown;"> incoming: 012345678  group- supermoney     fronter:  - 992236  uid: y3281602190002004448</span>';  $pattern = '/(?:fronter:  - )[0-9]{1,6}/i';      preg_match($pattern, $str, $matches);  print_r($matches);  /*** ^^^^^^^ prints :*/  array ( [0] => fronter: - 992236 )  in case of fronter not - or spaces don't fronter - number.
can example works in case, there fronter , number.
you can use fronter:\w*[0-9]{1,6} 
fronter:\w*[0-9]{1,6} : match fronter: 
- \w*: 0 or more non-word characters
- [0-9]{1,6}1 6 digits
you regex find match fronter:99222236 must use \b avoid overflow digit length
Comments
Post a Comment