Returns 'result' group value from a possible match with regex on a given content >>> extractRegexResult(r'a(?P [^g]+)g', 'abcdefg') 'bcdef' >>> extractRegexResult(r'a(?P [^g]+)g', 'ABCDEFG', re.I) 'BCDEF'
(regex, content, flags=0)
| 3126 | |
| 3127 | @cachedmethod |
| 3128 | def extractRegexResult(regex, content, flags=0): |
| 3129 | """ |
| 3130 | Returns 'result' group value from a possible match with regex on a given |
| 3131 | content |
| 3132 | |
| 3133 | >>> extractRegexResult(r'a(?P<result>[^g]+)g', 'abcdefg') |
| 3134 | 'bcdef' |
| 3135 | >>> extractRegexResult(r'a(?P<result>[^g]+)g', 'ABCDEFG', re.I) |
| 3136 | 'BCDEF' |
| 3137 | """ |
| 3138 | |
| 3139 | retVal = None |
| 3140 | |
| 3141 | if regex and content and "?P<result>" in regex: |
| 3142 | if isinstance(content, six.binary_type) and isinstance(regex, six.text_type): |
| 3143 | regex = getBytes(regex) |
| 3144 | |
| 3145 | match = re.search(regex, content, flags) |
| 3146 | |
| 3147 | if match: |
| 3148 | retVal = match.group("result") |
| 3149 | |
| 3150 | return retVal |
| 3151 | |
| 3152 | def extractTextTagContent(page): |
| 3153 | """ |
no test coverage detected
searching dependent graphs…