I am getting a string in this form:
my_string = "select \\\"ASSETS\\\" AS \\\"LEASE_ASSETS\\\", count(*) CNT FROM \\\"SIY\\\".\\\"I7_MAIN_ACCOUNT\\\" group by \\\"ASSETS\\\" order by \\\"ASSETS\\\""
I want to remove these \\\, but I am not sure if str.replace() is a good option.
The main thing I want is to get this Table name part from it, like this:
"SIY.I7_MAIN_ACCOUNT"
… which, due to those spaces, I am not able to get. I want to do it by using str.replace(), but it seems both are not working.
>Solution :
If query will be the same then you filter un wanted things one by one then extract your required words
import re
my_string = "select \\\"ASSETS\\\" AS \\\"LEASE_ASSETS\\\", count(*) CNT FROM \\\"SIY\\\".\\\"I7_MAIN_ACCOUNT\\\" group by \\\"ASSETS\\\" order by \\\"ASSETS\\\""
my_string= my_string.replace("\\", '').replace('"', '')
print (my_string[my_string.find('FROM ')+len('FROM '):my_string.rfind('group')])
Gives #
SIY.I7_MAIN_ACCOUNT