Search code examples
phpregexpreg-matchbundle-identifier

Catch bundle identifier com.company.app in file name


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


Solution

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

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

    DEMO