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
// Node 1: index_elements at index 0 — extracts the whole match as a String
1564
+
// Node 1: extract_element at index 0, extracts the whole match as a bare String (drops the row's start/end/name attributes since the unwrapped String can't carry them)
/// The index of the item to retrieve, starting from 0 for the first item. Negative indices count backwards from the end of the collection, starting from -1 for the last item.
/// Extracts every matched value from a JSON string using a path expression (see that parameter's description for its syntax). A list of zero or more resultant strings is produced. The `[]` path accessor is used to read more than one value.
217
217
///
218
+
/// Each row carries a `type` attribute holding the matched value's JSON type (`"string"`, `"number"`, `"bool"`, `"null"`, `"object"`, or `"array"`).
219
+
///
218
220
/// This is useful in conjunction with the nodes:
219
221
/// • **Index Elements**: access the `N`th query result.
220
222
/// • **String to Number**: convert numeric query results to numbers.
Copy file name to clipboardExpand all lines: node-graph/nodes/text/src/regex.rs
+21-4Lines changed: 21 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,9 @@ fn regex_replace(
80
80
/// Finds a regex match in the string and returns its components. The result is a list where the first element is the whole match (`$0`) and subsequent elements are the capture groups (`$1`, `$2`, etc., if any).
81
81
///
82
82
/// The match index selects which non-overlapping occurrence to return (0 for the first match). Returns an empty list if no match is found at the given index.
83
+
///
84
+
/// Each row carries `start` and `end` byte-offset attributes pointing into the original string, plus a `name` attribute holding
85
+
/// the capture group's name (empty for unnamed groups, and for index 0 which is the whole match).
83
86
#[node_macro::node(category(""))]
84
87
fnregex_find(
85
88
_:implCtx,
@@ -111,6 +114,9 @@ fn regex_find(
111
114
returnTable::new();
112
115
};
113
116
117
+
// Capture group names indexed positionally; index 0 (the whole match) is always None.
118
+
let capture_names:Vec<Option<String>> = regex.capture_names().map(|name| name.map(str::to_string)).collect();
119
+
114
120
// Collect all matches since we need to support negative indexing
115
121
let matches:Vec<_> = regex.captures_iter(&string).filter_map(|c| c.ok()).collect();
116
122
@@ -131,12 +137,20 @@ fn regex_find(
131
137
132
138
// Index 0 is the whole match, 1+ are capture groups
0 commit comments