Replace Line Breaks with commas

Say I have this list:
apples

bananas

oranges

pears

mangoes

And I want this list:

apples, bananas, oranges, pears, mangoes

What action could I use? At the moment I use MS Word for this. Search for ^p and replace with ,

But I can’t find how to do it in Drafts. Thanks!

Drafts has advanced find and replace features, so if this is just something you need to do now and then, they should suffice. Using “Regular Expressions” enabled, you could do something like this:

If you want an action to run that cleans up a draft like this because it is something you do regularly and want to automate, it would be a script that uses Javascript to make the replacements, something like:

// get text from editor
let text = editor.getText()

// do the replacements
text = text.replace(/\n+/g, ", ")

// update the editor
editor.setText(text)
2 Likes

Fantastic! Thank you so much!

If you use Apple Intelligence, you can tell it what you want to do and provided it is accessing ChatGPT will do it. However, Apple limits its context window a lot so even if you have it connected to a paid ChatGPT account, you can only reformat relatively small blocks of text–less than a page, in my experience. It is very versatile even if limited.

1 Like