php - regex inside tags with specified string -


i'm not @ regex have string :

 $str = '<span id="mainstatusspan" style="background: brown;"> incoming: 012345678  group- supermoney &nbsp;   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

fronter:[- ]*[0-9]{1,6}\b


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -