You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/pipedream_utils/actions/extract-by-regular-expressions-list/extract-by-regular-expressions-list.mjs
+56-59Lines changed: 56 additions & 59 deletions
Original file line number
Diff line number
Diff line change
@@ -4,77 +4,74 @@ export default {
4
4
name: "Formatting - [Text] Extract by Regular Expressions List (Regex)",
5
5
description: "Find matches for regular expressions. Returns all matched groups with start and end position.",
description: "Text you would like to find a pattern from",
11
+
alert: {
12
+
type: "alert",
13
+
alertType: "info",
14
+
content: "Start by defining the keys you want to extract. Each key will have its own input and regex configuration.\nMake sure to Refresh the fields at the bottom after changing a configuration.",
15
15
},
16
-
regExpStrings: {
16
+
keys: {
17
17
type: "string[]",
18
-
label: "Regular Expressions",
19
-
description: "An array of [regex strings](https://www.w3schools.com/js/js_regexp.asp) (e.g. `/foo/g`, `/bar/i`)",
18
+
label: "Keys",
19
+
description: "The list of keys to use for the result map",
20
+
reloadProps: true,
20
21
},
21
22
},
22
-
methods: {
23
-
getAllResults(input){
24
-
constresultMap={};
25
-
constresultList=[];
26
-
27
-
for(constrStrofthis.regExpStrings){
28
-
if(typeofrStr!=="string"||!rStr.length){
29
-
// still push an empty array to preserve order
30
-
resultMap[rStr]=[];
31
-
resultList.push([]);
32
-
continue;
33
-
}
34
-
35
-
constre=rStr.startsWith("/")
36
-
? buildRegExp(rStr,[
37
-
"g",
38
-
])
39
-
: newRegExp(rStr,"g");
40
-
41
-
constmatches=[
42
-
...input.matchAll(re),
43
-
].map((m)=>({
44
-
match: m[0],
45
-
groups: m.groups??{},
46
-
startPosition: m.index,
47
-
endPosition: m.index+m[0].length,
48
-
}));
49
-
50
-
resultMap[rStr]=matches;
51
-
resultList.push(matches);
23
+
additionalProps(){
24
+
constprops={};
25
+
for(constkeyofthis.keys){
26
+
if(this.isKeyValid(key)){
27
+
props[`${key}Input`]={
28
+
type: "string",
29
+
label: `Input for: ${key}`,
30
+
description: `The text you would like to find a pattern from for **${key}**`,
31
+
};
32
+
props[`${key}RegExp`]={
33
+
type: "string",
34
+
label: `Regular Expression for: ${key}`,
35
+
description: `[Regular expression](https://www.w3schools.com/js/js_regexp.asp) to use for **${key}**`,
0 commit comments