preg_match last characters after hyphen

32 views Asked by At

Can anybody help me please. I get an url and need to take the last part after -.

Example data

  • game-when-no-one-at-xhU8c0dL
  • coins-at-the-desk-1xhz83c
  • example-example-1391340

Result needed

  • xhU8c0dL
  • 1xhz83c
  • 1391340

I just made a regex to take some last characters, but number of symbols can be 7 or 8.

preg_match('/.{7}(?=($|\r|\n))/')

Edit

This will work: preg_match('/[^-]*$/')

0

There are 0 answers