Find in text
Finds dates, links, emails, phone numbers, addresses, flights, colours, numbers, money, lengths of time, hashtags or mentions in text.
Find kind in text
Details #
Looks through text for one kind of thing and returns everything it finds, in reading order. The result is the step's output and, with into, a variable. Finding nothing is not an error: you get an empty list.
kind is one of:
date: a date or time in everyday wording (next Friday at 3pm,Nov 14 at 9:30).valueis seconds since 1970; adurationin seconds is added when the text gives one.link: a web address.valueis the link.email: an email address.valueis the address, withoutmailto:.phone: a phone number, as written.address: a street address.valueis a record withstreet,city,state,zipandcountry.flight: a flight such asUA 123.valueis a record withairlineandflight.color:#rgb,#rrggbb,#rrggbbaa,rgb()orhsl()written in the text.valueis the record parseColor returns. Colour names in ordinary prose are not matched.number: a plain number with grouping, decimals, a minus or a percent (1,234.50,-5,12%).valueis the number.money:$12.50,EUR 3,12 USD,£1,200.valueis a record withamountandcurrency.duration: a length of time with a unit (1h 30m,90 minutes,2 days).valueis seconds.hashtag:#idea.valueis the tag without the#.mention:@kyle.valueis the name without the@. An email address is not a mention.all: every kind at once. Where two matches overlap, the more specific one wins (link, email, phone, address, flight, date, money, duration, colour, number, hashtag, mention), so the digits of a phone number are not also a number.
Each item is a record with kind, text (what matched), start and length (counted in UTF-16 units, as macOS counts text) and value.
With first on, the result is only the first item, or nothing when there is none.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
text | text | Yes | The text to look through. | |
first | yes / no | Return only the first item instead of a list. Off by default. | ||
into | text | The variable that receives the result. | ||
kind | one of | date link email phone address flight color number money duration hashtag mention all | What to find. The default is date. | |
value | text |
Every step also accepts label, onFailure, timeout and dryRunSafe.
Examples #
- Find link in “Docs at example.com/docs and…”
- Show “{{ length(links) }} links” for 2 s
Take the first amount of money:
- Find money in “Lunch was $12.50, tip $3”
- Show “{{ price.value.amount }} {{ price.value.currenc…” for 2 s
Gotchas #
It is safe in a dry run: it only reads the text it is given.
Dates are found with the system's own detector, so wording like
next Fridayis read against the real clock.An unknown kind fails and lists the valid ones.
The same search is available in expressions as find and findFirst.