What's the best way to search a number and replace it after calculation in a string by Python?
Question: For example. I have a string: "[bezierPath moveToPoint: CGPointMake(7.98,
6.11)];". I want to do some calculation on the two float number and replace
them.


Answer: You can use `re.sub`:

    
    
    >>> import re
    >>> def action(matchObj):
    ...     return str(float(matchObj.group(0)) * 2)
    ... 
    >>> re.sub('\d+\.\d+', action, "[bezierPath moveToPoint: CGPointMake(7.98, 6.11)];")
    '[bezierPath moveToPoint: CGPointMake(15.96, 12.22)];'
    

