How should I extract the string from paragraph using Python? The input: I got the email from your company for the refund of the ticket, here is my identity Flight no: XX 888 Route: USA-THA Date: Sunday, 2 December 2010 Name: Richard Kylie and the output is ```lang-none Name: "Richard Kylie" flight_no: "XX 888" date:"Sunday 2 December 2010" route:"USA-THA" ```
```python import re def extract_mentions(text): regex = ("Flight no:\s(\w+)\s(\w+)") return re.findall(regex, str(text)) string :'I got the email from your company for the refund of the ticket, here is my identity Flight no: XX 888 Route: USA-THA Date: Sunday, 2 December 2010 Name: Richard' mentions = extract_mentions(string) print('Flight:', mentions) ``` and the output is ```python Flight: [('XX', '888')] ``` and my desired output is: ```python Name: "Richard Kylie" flight_no: "XX 888" date:"Sunday 2 December 2010" route:"USA-THA" ```
[ "Flight no", "Route", "Date", "Name" ]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)