I have a dynamic string and I would like to remove the first attribute of an item it could find. I have the following code:
mystring = '''
item 1
item 2
*item 3
item 4
*item 5
'''
mystring = mystring.replace('*', '')
print((mystring))
This returns:
item 1
item 2
item 3
item 4
item 5
But I want it to only replace the first instance of * which in this case is *item 3. It should return:
item 1
item 2
item 4
*item 5
I basically want it to delete the first line that starts with * How can I go about doing this? Do I need to use regex?