Note Refactor & Templater plugins - help required to split a string

What I’m trying to do

I am using the templater plugin together with the Note Refactor plugin to do the task described in the more-detail section below, and to achieve this, I think that what I need is a user script, split_string, called as follows:
<% tp.user.split_string({{new_note_title, " ", 2}}) %>
or possibly
<% tp.obsidian.split_string({{new_note_title, " ", 2}}) %>
where split_string, as called above, returns the second word in the string new_note_title, where the space is the separator. It seems likely that a function to split strings might exist in the Obsidian API…?
I know how to code, but I am a newbie to Obsidian, and I haven’t used JavaScript before.

More detail

I have a note that has three titled sections, which are formatted using Heading 3. The format of the three headed sections is Author - Book Title - Page Number. I set it up that way, I can set it up differently if necessary.

I want to use Note Refactor to extract this note to three new notes, where it creates three new properties in the new note, one for Author, one for Book Title, and one for Page, which is what the number at the end of each heading refers to. I have hundreds of notes like this. So, if I have the three headings as formatted above, I want Note Refactor to split the string into three, and assign the results to three properties in each of the new notes - Author (Andy Summers), Book Title (One Train Later), and Page (98, in the first example above). The new note would look like this:

This is how I would imagine this would work, from the settings:

Any help greatly appreciated…

I have the solution to this now. I created a user function in the way that I had thought it would work. I’d like to say this was thanks to my impeccable coding skills, but…I went to ChatGPT and asked. It took three tries to phrase the question in the right way, and when I did, ChatGPT provided me with the exact code required.

Here is what I asked ChatGPT:

create a user function in obsidian that will return a given element of a delimited string

Here is what it came back with:

I’ve messed around with more complicated questions since I posted this question, and ChatGPT doesn’t always come back with the right answer. But for the question above, it did.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.