hack : power find/replace text

this tip is borne out of frustration at seeing humans do things the hard way when there’s a perfectly simple, less insane way.

i need to convert text from a brief which looks like this :

into an applescript list that looks like this :

screengrab showing applescript list

transforming the text manually is about as inefficient as things get. this is an ideal job for find/replace. it just takes a few seconds to figure out the best way to attack it.

the trick is to remember that find/replace isn’t only for letters, words and spaces. it can also be used on invisible characters like tabs and line breaks.

this particular task can be achieved with just two find/replace passes – then a little cleanup.

any text editor will do, but for this kind of thing i always use BBEdit
(note : this is NOT a paid endorsement – i just love the app)

when i copy the text from word to BBEdit it looks like this :

the first pass changes the text between the numbers :

the second pass changes basically everything else :

(notice how BBEdit specifies the line break as ‘/n’ and the tab as ‘/t’)

then i just need to manually clean up the top and tail :

and we’re done.

keep grunting.

thoughtful and respectful comments welcome

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s