rohit nair rohit nair - 10 months ago 30
Python Question

How to get the the required data from a string using Regexp or any string manipulation method

I have many Json responses from an instagram API which contains data like this:-

"bio": "


This regex seems to do an acceptable job:

(?i)([\w.]+@[\w.]+)|(?:(?:\b|[,/]\s*)(?:whatsapp|viber|wechat))+\b\s*[::]?\s*([()+\d -]+)|\bline(?:\sid)?\s*(?:[::]\s*)?(@\w+)|((?:\+\d+)?[ -]?(?:\(\d+\)[ -]?)?[\d -]{6,}\d)


This captures emails in capture group 1, Whatsapp/Viber/Wechat numbers in group 2, and line IDs in group 3.

Usage example:

import re

text= '