找回密码
 加入
搜索
查看: 2751|回复: 3

[系统综合] 【已解决】正则获取Android APK Version

[复制链接]
发表于 2013-9-3 08:14:54 | 显示全部楼层 |阅读模式
本帖最后由 touch_xu 于 2013-9-5 19:58 编辑

for example:
<package name="com.android.emulator.gps.test"
codePath="/system/app/GpsLocationTest.apk"
nativeLibraryPath="/data/app-lib/GpsLocationTest" flags="48709"
ft="13cd42b5c48" it="13ae2db2680" ut="13cd42b5c48" version="17"
userId="10016">
<sigs count="1">
<cert index="0" />
</sigs>
</package>

<package name="com.android.development"
codePath="/system/app/Development.apk"
nativeLibraryPath="/data/app-lib/Development" flags="572997"
ft="13cd42b5c48" it="13ae2db2680" ut="13cd42b5c48" version="1"
userId="10014">
<sigs count="1">
<cert index="1" />
</sigs>
</package>

我要的结果
GpsLocationTest.apk=17

Development.apk=1

求教
发表于 2013-9-3 12:23:45 | 显示全部楼层
Local $Str = _
                '<package name="com.android.emulator.gps.test"' & @CRLF & _
                'codePath="/system/app/GpsLocationTest.apk"' & @CRLF & _
                'nativeLibraryPath="/data/app-lib/GpsLocationTest" flags="48709"' & @CRLF & _
                'ft="13cd42b5c48" it="13ae2db2680" ut="13cd42b5c48" version="17"' & @CRLF & _
                'userId="10016">' & @CRLF & _
                '<sigs count="1">' & @CRLF & _
                '<cert index="0" />' & @CRLF & _
                '</sigs>' & @CRLF & _
                '</package>' & @CRLF & @CRLF

Local $sRE = StringRegExpReplace($str, '(?si).+?codePath=.*?([^/"]+)".+?n="(.*?)".*', '$1=$2')
MsgBox(0, $sRE, $Str)
发表于 2013-9-3 12:26:08 | 显示全部楼层
$str='<package name="com.android.emulator.gps.test"' & @crlf & _
        'codePath="/system/app/GpsLocationTest.apk"' & @crlf & _
        'nativeLibraryPath="/data/app-lib/GpsLocationTest" flags="48709"' & @crlf & _
        'ft="13cd42b5c48" it="13ae2db2680" ut="13cd42b5c48" version="17"' & @crlf & _
        'userId="10016">' & @crlf & _
        '<sigs count="1">' & @crlf & _
        '<cert index="0" />' & @crlf & _
        '</sigs>' & @crlf & _
        '</package>' & @crlf & _
        '<package name="com.android.development"' & @crlf & _
        'codePath="/system/app/Development.apk"' & @crlf & _
        'nativeLibraryPath="/data/app-lib/Development" flags="572997"' & @crlf & _
        'ft="13cd42b5c48" it="13ae2db2680" ut="13cd42b5c48" version="1"' & @crlf & _
        'userId="10014">' & @crlf & _
        '<sigs count="1">' & @crlf & _
        '<cert index="1" />' & @crlf & _
        '</sigs>' & @crlf & _
        '</package>'
MsgBox(0,"",$str)
$str=StringRegExpReplace($str,"[\s\S]*?(GpsLocationTest\.apk|Development\.apk)[\s\S]*?version\=""(\d+)[\s\S]*?\<\/package\>\s*","$1=$2"&@crlf)
MsgBox(0,"",$str)
试一下
 楼主| 发表于 2013-9-5 19:57:40 | 显示全部楼层
感谢A版,感谢kevinch,很完美,谢谢!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-16 19:12 , Processed in 0.078302 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表