I have a very large string and I like to find a small string or value inside it (in my example 14). A snippet of it looks like this:
I need to retrieve 14. The catch is that 78 is dynamic and I get it's value from a dict (someDict)
str1='dnas ANYTHING Here <td class="tr js-name"><a href="/myportal/report/78/abc/xyz/14" title="balh">blah</a></td>'
str2="/myportal/report/"+str(someDict["Id"])+"/abc/xyz/"
p = re.compile(r'str2\s*(.*?)\"')
match = p.search(str1)
if match:
print(match.group(1))
else:
print("cant find it")
I know there is something wrong with --> p = re.compile(r'str2\s*(.*?)\"')
since I cant just stick in str2
, how do I go about using compile please