Regex

I dabbled with regex a few years back and failed miserably.

I am trying to do two things, and dont know where to start. Heres my examples

1)

Code Code CODERS

should be

Code Code Coders

2)

Code Code CODERSFunny

should be

Code Code Coders Funny

Whats the best approach? Does anyone have examples

How about

sed 's/CODERS\([^ ]\|$\)/Coders \1/' file
Code Code Coders 
Code Code Coders Funny
1 Like

Or this simple one:

sed 's/CODERS */Coders /' file

Yes, but this will add a space even if the original line ends after the word. Which, BTW, post#2 does as well . . . hmmm. Try

sed '/CODERS */ {s//Coders /; s/ $//;}' file