The regex does the job. But I am facing a problem here. It also replaces the occurrences within <a href tag..
I am facing a problem as described below
modified_contents = re.sub("([^http://*/s]APP[a-z]{2}[0-9]{2})", "<a href=\"http://python.com=\\1\">\\1</a>", str)
Sample input 1:
Input File contains APPdd34
Output File contains <a href="http://python.com=APPdd34"> APPdd34</a>
Sample input 2:
Input File contains <a href="http://python.com=APPdd34"> APPdd34</a>
Output File contains <a href="http://python.com=<a href="http://python.com=APPdd34"> APPdd34</a>"> <a href="http://python.com=APPdd34"> APPdd34</a></a>
Desired Output File 2 is same as Sample Input File 2.
How can I rectify this problem?