正则表达式中的组是什么类型的容器

时间:2019-06-18 05:33:14

标签: python regex

正则表达式组是列表吗?我可以做这样的事情吗?

with open(filename) as infile:
    for line in infile:
        self._match = (re.search('^CIS\s(\d*\w*)(\w*)\s?[^x]*(.*)$', line, re.I))
        self._numb = self._match.group(0).strip()
        self._name = self._match.group(1).strip()
        self._quarter=self._match.group(2).strip().split('x')

1 个答案:

答案 0 :(得分:3)

Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:8:5-23:19 to override. 实际上是属于match对象的函数。例如,调用 configurations.all { resolutionStrategy.force 'com.android.support:design:28.0.0' resolutionStrategy.force "com.android.support:support-v4:28.0.0" resolutionStrategy.force "com.android.support:support-media-compat:28.0.0" } ... dependencies { implementation 'com.android.support:multidex:1.0.1' // Our dependencies implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0' } 将返回与该特定组匹配的任何字符串。调用group()将返回一个包含所有匹配项的元组。对于_match.group(1),返回值将是一个元组列表,每个元组包含所有组。