I want to replace all 1.5.1234.78(25) by #1.5.1234.78(25)# this is what i do :
string ="""
sdfdfs 1.5.1234.78(25) sfsddsf
1.5.1234.78(25)
1.5.1234.78(25) ddfssfd
dsdsfdfs 1.5.1234.78(25)
1.5.1234.78(25)sdfdsf"""
print(string)
string = re.sub(r'\b{}\b'.format('[0-9]{1}\.[0-9]{1}\.[0-9]{4}\.[0-9]{2}\([0-9]{2}\)'), r'#\g<0>#', string)
print(string)
output :
sdfdfs 1.5.1234.78(25) sfsddsf
1.5.1234.78(25)
1.5.1234.78(25) ddfssfd
dsdsfdfs 1.5.1234.78(25)
#1.5.1234.78(25)#sdfdsf
why this 1.5.1234.78(25)sdfdsf is replaced by #1.5.1234.78(25)#sdfdsf
i spicify the \b to take only pattern at the beginning and end of a word !
i want have something like this :
sdfdfs #1.5.1234.78(25)# sfsddsf
#1.5.1234.78(25)#
#1.5.1234.78(25)# ddfssfd
dsdsfdfs #1.5.1234.78(25)#
1.5.1234.78(25)sdfdsf