I am new in python.I have data in a 2d- array in the following format.
array[0] array[1]
Arkan Adrian Edmondson
Efgan All Rik
'Til Death Do Us Part (Star Trek: Deep Space Nine) Bradley Thompson
'Til Death Do Us Part (Star Trek: Deep Space Nine) David Weddle
Billy Sherrill 'Til I Can Make It on My Own (Deep Space)
I want to match this string for each line in a file, if matches both array then I want to return the line.
First, I want search the both array in each line .For that my attempt was:
def strinMach(domainL, rangeR):
text = ""
filetext = open(File, "r").read()
sentlist = re.split(u'[\n|\r\n]+',filetext)
for i in sentlist:
if domainL in i and rangeR in i:
text = text + i + "\n"
elif (To search for without the parenthesis string from array[0] & array[1]
eg.search with (Til Death Do Us Part Bradley Thompson ) )
elif (To search with some string from array[0] & array[1]
es. search with(Till Death Bradley) or (Do Us Part Thompson))
return text
My second step is seraching with the array except the parenthesis string (i.e except (terms)
).
And third step with the substring of both array.
How to proceed on for 2nd & 3rd step.
Any kind of help will be greatly appreciated.
Thanks!!!!!!!
I’m having a bit of trouble working out what you’re asking, but maybe this will help:
You can remove a bracketed section of a string with:
(N.B. This won’t work properly if you have “((nested) brackets)”)
You can get substrings by slicing: