Good way to select blank lines?

I’m moving lists from various programs, many of which feature the now seemingly-standard “quirky” MD-lite text editors. What are the good ways to select all the empty lines in a .bike file?

I tried copying and pasting a black line in the search field. I tried Regex for \n and \r and matched nothing. Which likely informs you as to my level of RegExpertise, which has stalled at around the third quintile, gazing lustily at LookAheads.

You may not need to use regular expressions.

See, for example the code listings in:

1 Like

PS

broadly, you can get a reference to all blank lines with an expression like:

doc.rows.where({name: ""})

and you call that function reference and convert it to an Array of results by appending ()

So, for example:

Expand disclosure triangle to view JS source
(() => {
    "use strict";

    const
        bike = Application("Bike"),
        doc = bike.documents.at(0);

    return doc.exists() ? (() => {
        const
            refBlankRows = doc.rows.where({name: ""}),
            listOfBlankRows = refBlankRows();

        return [
            Automation.getDisplayString(refBlankRows),
            typeof refBlankRows,
            Array.isArray(listOfBlankRows),
            `Count from function reference: ${refBlankRows.length}`,
            `Count from derived array: ${listOfBlankRows.length}\n`,
            "IDs of all blank lines:",
            refBlankRows.id()
            .join(" ")
        ].join("\n\n");
    })() : "No documents open in Bike";
})();

and in terms of AppleScript:

Expand disclosure triangle to view AppleScript source
tell application "Bike"
    set doc to front document
    
    if doc exists then
        tell doc
            set refBlankRows to a reference to (rows where its name is "")
            
            -- IDs of all blank rows:
            id of refBlankRows
        end tell
    else
        "No document open in Bike"
    end if
end tell
2 Likes

Magic to me :clap: . Thank you.

And thank you for the additional exemplary work packaging your KMacro so that is easily procured, installed, stored, and used.

2 Likes