Need RegEx for find comma and replace | with handling double quotes in python

  python, python-2.7, python-3.x

I have string like :

8/30/2021 19:22,server1,app1,"user1, Mrs. user2",US,One,Email, Sent,Success

Expected Output :

8/30/2021 19:22|server1|app1|user1, Mrs. user2|US|One|Email| Sent|Success

My code looks like :

....
line = line.replace(',', '|')
print (line)

How to handle double quotes in python using RegEx ?

Source: Python-3x Questions

LEAVE A COMMENT