matteo matteo - 2 years ago 109
Python Question

Find text between strings python

I looked at similar question and answers but could not solve my issue.

I have a string, like the following:

ecc, ecc, .....thisIsUnique("92781227-7e7e-4768-8ee3-4e1615bddf3c", ecc, ecc.......

could be very long before and after without having some unique text.

What I need is to get the
code as string. So I'm looking to something that ca sound like:

when you find
go ahead, read the code after you find the first
characters and keep reading until you find the first

Unfortunately I'm not familiar with regex, but maybe there are different ways to solve the problem

thanks to all

Answer Source

There are a few sites you should read up on for what regex is. and Learning Regular Expressions Use a site like this to test what you have tried: But to get you started, this runs exactly what you have pasted as an example:

import re

text = 'ecc, ecc, .....thisIsUnique("92781227-7e7e-4768-8ee3-4e1615bddf3c", ecc, ecc.......'
match ='thisIsUnique\("([^"]+)', text)
print (


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download