You need regular expressions for this:
import re
s="abc xyz.xyz(1, 2, 3) pqr"
re.sub(r'[a-z]{3}\.{[a-z]{3}\([^)]*\)', 'NULL', s)
Explanation:
[a-z]{3}
stands for 3 small letters (lower case)\.
escapes the dot, as it is special character[a-z]{3}
again 3 small letters\(
escapes the left parenthesis[^)]*
any character but right parenthesis, 0 or more time\)
escapes the right parenthesis
1
solved Regex for replacing certain string in python [closed]