Get Android OS version from user-agent

前端 未结 5 806
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 11:21

I\'ve been trying to find a parser or regex that will give me the Android OS version from a user agent string.

E.g.

Mozilla/5.0 (Linux; U; Android 2.         


        
5条回答
  •  渐次进展
    2020-12-08 11:56

    If you want to use it with User-Agent it might be safe but else you shouldn't use it.

    Android ((\d+|\.)+[^,;]+)
    

    It catches everything after Android it works with,

    1.6 2.4.4 10.12.5

    To test with Live Regex: https://www.phpliveregex.com/p/uPw

提交回复
热议问题