findFirst
The first thing of a kind found in text, or nothing.
Details #
findFirst(kind, text) takes two arguments and returns the first item find would give, or nothing (null) when there is none.
kind is date, link, email, phone, address, flight, color, number, money, duration, hashtag, mention, all, or several separated by commas such as "date,link". What each one finds, and what its value is, is on the Find in text page.
Each item is a record with kind, text (what matched), start and length (UTF-16 offsets, as macOS counts text) and value. Dates also have duration when the text gives one. With several kinds, items come back in reading order, and where two overlap the more specific kind wins.
Parameters #
Takes 2 arguments.
{{ findFirst(text, b) }}
Examples #
findFirst("date", "Lunch on Nov 14 at 9:30").value1794670200findFirst("money", "Total: $12.50").value.amount12.5Gotchas #
Nothing found gives
null, so test it before reading.value.An unknown kind is an error that lists the valid ones.