使用regex python在新行之后提取所有行

时间:2014-10-15 08:24:36

标签: python regex string

我有这个字符串:

Packages:
Package [com.bizportal] (42662eb0):
userId=10086 gids=[3003]
pkg=Package{42c3b300 com.bizportal}
codePath=/data/app/com.bizportal-1.apk
resourcePath=/data/app/com.bizportal-1.apk
nativeLibraryPath=/data/app-lib/com.bizportal-1
versionCode=20 targetSdk=9
versionName=2.1.2
applicationInfo=ApplicationInfo{42bf7108 com.bizportal}
flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ]
dataDir=/data/data/com.bizportal
supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity]
timeStamp=2014-09-09 21:19:29
firstInstallTime=2014-09-09 21:19:29
lastUpdateTime=2014-09-09 21:19:29
installerPackageName=com.android.vending
signatures=PackageSignatures{42666c98 [42663998]}
permissionsFixed=true haveGids=true installStatus=1
pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ]
User 0:  installed=true blocked=false stopped=false notLaunched=false enable    d=0
grantedPermissions:
  android.permission.CALL_PHONE
  android.permission.READ_PHONE_STATE
  android.permission.INTERNET
  android.permission.ACCESS_NETWORK_STATE

我希望获得授权后的所有行: 我试试这个:

(?:grantedPermissions:)(.+)

但它什么也没有返回 建议?

1 个答案:

答案 0 :(得分:1)

(?<=grantedPermissions:)(.+)

试试this.Set标志re.DOTALL。见演示。

http://regex101.com/r/uH3tP3/13