search

Home  >  Q&A  >  body text

Regular expression problem

$a = '<img  src="/resource/public/game/2015/4/17/360aae11-78fc-4d91-b016-0995918039a4.gif" width="90" height="90">   
 <img  src="/resource/public/game/1414944000/599afd66-8740-47b6-b935-68d427fa5821.jpg" width="90" height="90">';
 
 
 $b = '/\b\/.+(?=" width\b)/';
preg_match_all($b, $a, $c);

var_dump($c);
array(1) {
  [0]=>
  array(2) {
    [0]=>
    string(72) "/resource/public/game/2015/4/17/360aae11-78fc-4d91-b016-0995918039a4.gif"
    [1]=>
    string(52) "/1414944000/599afd66-8740-47b6-b935-68d427fa5821.jpg"
  }
}

I want to match the picture name, how should I match it?

360aae11-78fc-4d91-b016-0995918039a4.gif

599afd66-8740-47b6-b935-68d427fa5821.jpg

The idea is from the back Match forward to the first/end but I don’t know how to write

in front
按键盘手指磨破皮按键盘手指磨破皮2654 days ago1399

reply all(3)I'll reply

  • 寻觅 beyond

    寻觅 beyond2017-09-22 19:47:53

    Someone has already answered, let me make a suggestion. I suggest you use the explode() function to convert it into an array, and then use array_pop() to get the picture name

    reply
    0
  • 那山

    那山2017-09-21 10:17:53

    I can’t even understand this

    reply
    1
  • PHP中文网

    PHP中文网2017-09-21 09:05:08

    $b = '/src=[\'"][^\'"]+\/([^\'"\/]+)[\'"]/';

    this

    reply
    0
  • 按键盘手指磨破皮

    After further research, I found that this is better $b = '/b/[w-]{20}.+(?=" widthb)/';

    按键盘手指磨破皮 · 2017-09-21 10:34:15
  • Cancelreply