标题: [文本处理] 批处理怎样在文本中匹配制定的字符串? [打印本页]
作者: bywuyu 时间: 2013-3-12 20:30 标题: 批处理怎样在文本中匹配制定的字符串?
package: name='com.chaozh.iReaderFree15' versionCode='35' versionName='1.6.2.0'
application-label:'Palmebook'
application-label-zh_CN:'爱读掌阅'
application-label-zh_TW:'愛讀掌閱'
application-icon-120:'res/drawable-ldpi/icon.png'
application-icon-160:'res/drawable-mdpi/icon.png'
application-icon-240:'res/drawable-hdpi/icon.png'
application-icon-320:'res/drawable-hdpi/icon.png'
application: label='Palmebook' icon='res/drawable-mdpi/icon.png'
launchable-activity: name='com.chaozh.iReader.ui.activity.WelcomeActivity' label='' icon=''
sdkVersion:'4'
targetSdkVersion:'4'
uses-permission:'android.permission.READ_PHONE_STATE'
uses-permission:'android.permission.WRITE_SETTINGS'
uses-permission:'android.permission.SET_WALLPAPER'
uses-permission:'android.permission.INTERNET'
uses-permission:'android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission:'android.permission.ACCESS_NETWORK_STATE'
uses-permission:'android.permission.SEND_SMS'
uses-permission:'android.permission.CHANGE_WIFI_STATE'
uses-permission:'android.permission.ACCESS_WIFI_STATE'
uses-permission:'android.permission.WRITE_APN_SETTINGS'
uses-permission:'android.permission.CHANGE_NETWORK_STATE'
uses-permission:'android.permission.WAKE_LOCK'
uses-permission:'android.permission.VIBRATE'
uses-feature:'android.hardware.wifi'
uses-feature:'android.hardware.telephony'
uses-feature:'android.hardware.touchscreen'
uses-feature:'android.hardware.screen.portrait'
main
other-activities
other-services
supports-screens: 'small' 'normal' 'large'
supports-any-density: 'true'
locales: '--_--' 'zh_CN' 'zh_TW'
densities: '120' '160' '240' '320'
native-code: 'armeabi'
文本如上:
现在需要通过批处理获取出 versionCode='35' 中对应的数字 35.
可以确定是在第一行.
望打大侠指点...
作者: BAT-VBS 时间: 2013-3-12 20:50
- @echo off
- setlocal enabledelayedexpansion
- for /f "tokens=5 delims== " %%a in (a.txt) do (
- set str=%%a
- set str=!str:'=!
- goto :next
- )
-
- :next
- echo !str!
- pause
复制代码
作者: apang 时间: 2013-3-12 21:26
- @echo off
- set /p str=<a.txt
- for /f "delims=='" %%a in ("%str:*versionCode=%") do echo %%a
- pause
复制代码
作者: BAT-VBS 时间: 2013-3-13 16:42
- python -c "print open('a.txt').next().split(' ')[2].split('\'')[1]"
复制代码
http://www.bathome.net/thread-22973-1-1.html
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |