-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
Copy pathExtractBitcoinAddresses.mjs
56 lines (47 loc) · 1.29 KB
/
ExtractBitcoinAddresses.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @author homer.jonathan [[email protected]]
* @copyright Crown Copyright 2021
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
import { search } from "../lib/Extract.mjs";
/**
* Extract Bitcoin addresses operation
*/
class ExtractBitcoinAddresses extends Operation {
/**
* ExtractIPAddresses constructor
*/
constructor() {
super();
this.name = "Extract Bitcoin Addresses";
this.module = "Regex";
this.description = "Extracts all Bitcoin addresses in input provided. ";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
"name": "Display total",
"type": "boolean",
"value": false
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const displayTotal = args[0],
bitcoin = "(?:[13]{1}[a-km-zA-HJ-NP-Z1-9]{26,33}|bc1[a-z0-9]{39,59})";
const bitcoins = bitcoin;
if (bitcoins) {
const regex = new RegExp(bitcoins, "ig");
return search(input, regex, null, displayTotal);
} else {
return "";
}
}
}
export default ExtractBitcoinAddresses;