I have a function, call it f
, that takes a string and returns a string.
I have a file with lines that look like this:
stuff:morestuff:stuff*:otherstuff:otherstuff*\n
Colons only appear as delimiters and * only appears at the end of each word. I want to loop over the file and replace all instances of stuff* with f(stuff). The previous line would go to
stuff:morestuff:f(stuff):otherstuff:f(otherstuff)\n
I can do this in a few lines, but there must be a way to do it in one.
Edit To be clear, by f(stuff), I mean f called on "stuff", not the string "f(stuff)".