I have strings that may include numbers in square brackets. If they do I'd like to increment up the number in the final set of square brackets up by one.
old_content='Some text\t\t[1.00]\nSome other text'
So far i have code that does that, but doesn't feel pythonic.
open_indexes = [i for i, c in enumerate(old_content) if c == "["]
close_indexes = [i for i, c in enumerate(old_content) if c == "]"]
start = old_content[:open_indexes[-1]+1]
end = old_content[close_indexes[-1]:]
num = old_content[open_indexes[-1]+1:close_indexes[-1]]
num = float(num)+1
new_content =start +str(num) + end
Is there a more pythonic way of doing this?