Text handling in Shortcuts

I am trying to write a shortcut to add text to apple notes (mostly from the books app, so I have you exit books to access the shortcut).

I can easily strip the stuff that Apple adds at the end, but what I want to do is capture the tile and set it as the first line, then the quote, then the author. I can’t seem to figure out how to capture the matched text `Match “Excerpt from\n(.*) in Clipboard” doesn’t seem to what I expect…

Can you post a link to your current shortcut? That would help with troubleshooting

It’s not clear from where you are invoking the shortcut thus what content will be available.

It doesn’t work

Get iBook quote

Are you able to also share sample text? It would be helpful to see an example of the text you are copying to the clipboard and the corresponding desired output.

It is still not clear to me from where you are invoking this shortcut thus what text you will have to manipulate

I’ve tried, but can’t copy anything out of the books app at all,
How do you get a quote out?

It appears others are also having problems copying from iBooks. There are some solutions that might help on Apple Stack Exchange I hope it helps.

select text, tap “copy”, exit books, launch shortcut.

You cannot access shortcuts from inside Books’s share menu.

sample text:

“Alfred did offer to ransom me, but balked at Ragnar’s price that was ludicrously high, though not nearly so steep as the price Ivar and Ubba extracted from Burghred.”

Excerpt From
The Last Kingdom
Bernard Cornwell
This material may be protected by copyright.

What I want to do is get that second line and put it in front of the text, leave the third line, and remove lines 1 and 4. and make that a note. IU can do everything except move the second line to before the quote.

I don’t have a “copy” option after I select text, just Speak, Mark, Note and Search.

In the Books app on my phone an iPad when I select text I have Copy, Highlight, Note, Search, and Share.

I tested some more.
And apparently it depends on the book. Some have the Share option, and some don’t. Probably a rights issue

probably a DRM issue? All my epubs are DRM free. I make sure of that. Still, not relevant to the question which is how do I match a line of text and insert it at the front of the text?

Here is really simple example. This assumes the text will always be formatted as you show above. That is, a contiguous blurb of text, followed by one blank line, followed by the other lines. If that format is consistent, this will work for you.

If it is not, you will need a more sophisticated approach depending on the formatting

https://www.icloud.com/shortcuts/fee3ccb0f917467abee214b1f909eea6

n an iPad/iphone or on a mac? On a mac, in books, select some text. and a menu will appear where you can copy the selected text into notes, with a citation.

Barry

The question is categorised and about Shortcuts as well as iBooks. Shortcuts is not currently available on the Mac, and so it is referring to iPad/iPhone; though many people have their fingers crossed that this will change with WWDC next week. :wink:

That is too specific since if the quoted text crosses a paragraph boundary, the results in multiple lines.

Is it possible, after “split text by new lines” to then do something AppleScript-y like “item of split text whose text starts with “Excerpt”? Or is it possible to iterate over the split text in reverse order (since the last line of split text will be “This material” and split text - 2 will be the “title” I want).

Looks like I can get the last item, remove it, reprocess to get the author, remove it, reprocess to get the title, remove it, reprocess to get the “excerpt from”, remove it. The put text back together as <title>, <all the text that is left>, <author>.

I may see if there’s a session on all the improvements to shortcuts this week, because that sounds terrible.