Deleting Characters Between Two Different Keywords
i have a string like below. stg = 'Abel read (reading)|book(peripheral)~Q27.8#basillary NEC~Q28.1|| ' Requirement: Need to delete the character between two keywords ~ and # and the
Solution 1:
Using string.find method
stg = "Abel read (reading)|book(peripheral)~Q27.8#basillary NEC~Q28.1|| "
start= stg.find( '~' )
end= stg.find( '#' )
if start!=-1andend!=-1:
result= stg.replace(stg[start:end+1], "")
print result
Output:
Abel read (reading)|book(peripheral)basillary NEC~Q28.1||
Post a Comment for "Deleting Characters Between Two Different Keywords"