【已解决】正则获取Android APK Version
本帖最后由 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
求教 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) $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)试一下 感谢A版,感谢kevinch,很完美,谢谢!
页:
[1]