# Task 10: Extract values between quotation Write a Python program to extract values between quotation marks of a string. Sample data : '"Python", "PHP", "Java"' Sample output : ['Python', 'PHP', 'Java']
时间: 2024-01-20 10:04:34 浏览: 73
基于Python的stocks_quotation_quant_backtest股票报价量化回测设计源码
Here's a Python program to extract values between quotation marks of a string:
```python
import re
data = '"Python", "PHP", "Java"'
output = re.findall(r'"(.*?)"', data)
print(output)
```
Output:
```
['Python', 'PHP', 'Java']
```
Explanation:
- We first import the `re` module for Regex operations.
- The `data` variable contains the sample data string.
- We use the `re.findall()` function to extract all the substrings that match the regular expression pattern `"(.*?)"`. This pattern matches any sequence of characters between two double quotes.
- The `output` variable stores the extracted substrings as a list.
- Finally, we print the `output` list to display the extracted values.
阅读全文