0

I am wondering how to catch bundle identifier like com.company.appname in file name Great.app.ios9.1-com.company.appname.super-ultra.ipa using preg_match() in php.

Thanks

Maros Mayer
  • 67
  • 1
  • 7

1 Answers1

1

Just grab the dot separated words (upto the third dot) exists next to -.

$match = preg_match('~-\K(?:[^.]*\.){2}[^.]*~', $str);

DEMO

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
  • ok and it is possible to do it generaly, for example anywhere in file it can find it. Because for this it not working. `SparKauf-v1.1.3-mac-iOS7.0-(Ultra-1.4.7).at.spar.sparkauf.plist` – Maros Mayer Jan 11 '16 at 13:49
  • ok, I rearranged my file names so identifier started with two dashes like `Keynote_Remote-1.2--com.apple.iwork.KeynoteRemote.ipa` but there is a problem, sometimes identifier consists of three parts `domain.company.app` sometimes of fourparts `domain.company.subapp.app` like example above. It is possible to do regex, which accepts this two parts? – Maros Mayer Jan 11 '16 at 21:36