how to make text replacement in automator (regex)

Sorin Buturugeanu picture Sorin Buturugeanu · Nov 28, 2010 · Viewed 10.5k times · Source

I am making an Automator application and I need to replace some text based on a certain criteria. I am wondering if there is an Automator action for performing a regex text replacement.

If not, I always have the option to run an AppleScript that can do this, but I really don't know how to write AppleScript code.

Thanks!

Answer

Antal Spector-Zabusky picture Antal Spector-Zabusky · Nov 28, 2010

There's no dedicated Automator action for this, but you can use the "Run Shell Script" action. It can receive its input on stdin or as arguments, and you can just use sed, awk, perl, ruby, or whatever you're comfortable with to do the replacement.