Regular expression for preg_split.



  • Please help me correct the regular expression for the function. preg_split()

    preg_split('/^(photo)*([0-9])+_/','photo1542_123')
    

    We need a line photo1542_123 Breaking the mass

    `Array ( [0] =>photo [1] => 1542 [2] => 123 ) `.
    


  • Well, I'll put it as an answer:

    preg_match('/^(photo)(\d+)_(\d+)$/','photo1542_123', $m) 
    

    He'll return what he needs. $m[1]




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2