I want to replace the numbers in a block of text with their halved values, but only if the number is followed by certain words. For example:
14 apples and 18 bananas cost 6 dollars.
to
7 apples and 9 bananas cost 6 dollars.
here halving only the numbers followed by fruit names. I don’t think this is doable with a simple replace
, and I can’t figure out how to do it with a replace
callback.