regexp_extract_all()的返回值
时间: 2023-09-20 14:09:57 浏览: 124
`regexp_extract_all()` 是一个用于提取正则表达式匹配的所有子字符串的函数。它在字符串中查找所有与给定正则表达式匹配的子字符串,并将它们作为列表返回。
例如,假设有以下字符串:
```
text = "Hello, my name is John Doe. I live in New York. You can reach me at john@example.com or johndoe@gmail.com."
```
我们可以使用 `regexp_extract_all` 函数提取所有的电子邮件地址:
```python
import re
text = "Hello, my name is John Doe. I live in New York. You can reach me at john@example.com or johndoe@gmail.com."
emails = re.findall(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', text)
print(emails)
```
输出结果为:
```
['john@example.com', 'johndoe@gmail.com']
```
`regexp_extract_all()` 函数返回一个包含所有匹配项的列表。在这个例子中,它返回了两个电子邮件地址作为列表中的两个字符串元素。