[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] 批处理怎样在文本中匹配制定的字符串?

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.
可以确定是在第一行.

望打大侠指点...

  1. python -c "print open('a.txt').next().split(' ')[2].split('\'')[1]"
复制代码
http://www.bathome.net/thread-22973-1-1.html

TOP

  1. @echo off
  2. set /p str=<a.txt
  3. for /f "delims=='" %%a in ("%str:*versionCode=%") do echo %%a
  4. pause
复制代码

TOP

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for /f "tokens=5 delims== " %%a in (a.txt) do (
  4.     set str=%%a
  5.     set str=!str:'=!
  6.     goto :next
  7. )
  8. :next
  9. echo !str!
  10. pause
复制代码

TOP

返回列表