1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "strings": [
12 "John Doe, john.doe@example.com, +1 (415) 555-0132, https://example.com",
13 "Reach Jane at jane_smith@work.co.uk or call 020 7946 0958.",
14 "No contact details in this line."
15 ],
16 "patterns": [
17 {
18 "name": "email",
19 "regex": "[\\w.+-]+@[\\w-]+\\.[\\w.-]+",
20 "flags": "i"
21 },
22 {
23 "name": "phone",
24 "regex": "\\+?\\d[\\d\\s().-]{7,}\\d"
25 },
26 {
27 "name": "url",
28 "regex": "https?://[^\\s)\\]]+"
29 }
30 ]
31};
32
33
34const run = await client.actor("rl1987/regex-helper").call(input);
35
36
37console.log('Results from dataset');
38console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
39const { items } = await client.dataset(run.defaultDatasetId).listItems();
40items.forEach((item) => {
41 console.dir(item);
42});
43
44