Skip to content

Commit 9ebf4b6

Browse files
committed
Fix regex to allow mapping nested list items.
1 parent 7b469f0 commit 9ebf4b6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/src/api/regexes.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484
/// [a-zA-Z0-9_]* # Matches zero or more alphanumeric characters or underscores
8585
/// ) # End of the named capture group "name"
8686
/// (
87-
/// (?<accessor>\[\d+\]) # Named capture group "accessor" for array access:
88-
/// # - \[\d+\] matches one or more digits surrounded by square brackets
87+
/// (?<accessor> # Named capture group "accessor" for array access:
88+
/// (?:\[\d+\])+ # Non-capturing group for multiple occurrences of digits surrounded by square brackets
8989
/// |
9090
/// (?: # Non-capturing group for nested path access:
9191
/// \. # Matches a dot (for nested properties)
@@ -106,9 +106,9 @@
106106
/// 3. accessor: The array accessor applied directly to the variable.
107107
/// 4. path: The nested property path applied directly to the variable.
108108
///
109-
/// Try it out here: https://regex101.com/r/FOyWLJ/1
109+
/// Try it out here: https://regex101.com/r/FOyWLJ/2
110110
const String variablePathPattern =
111-
r'(?<!\\)\$\{(?<value>(?<name>[a-zA-Z][a-zA-Z0-9_]*)((?<accessor>\[\d+\])|(?:\.(?<path>[a-zA-Z]+[a-zA-Z0-9_]*(?:\[\d+\])*))*)?)\}';
111+
r'(?<!\\)\$\{(?<value>(?<name>[a-zA-Z][a-zA-Z0-9_]*)((?<accessor>(?:\[\d+\])+)|(?:\.(?<path>[a-zA-Z]+[a-zA-Z0-9_]*(?:\[\d+\])*))*)?)\}';
112112

113113
/// Regex for [variablePathPattern].
114114
final RegExp variablePathRegex = RegExp(variablePathPattern);
@@ -117,7 +117,7 @@ final RegExp variablePathRegex = RegExp(variablePathPattern);
117117
/// on $ or ${} curly braces in a string while the text/path is actively being
118118
/// composed.
119119
const String variablePathComposingPattern =
120-
r'(?<!\\)\$\{?(?<value>(?<name>[a-zA-Z][a-zA-Z0-9_]*)((?<accessor>\[\d+\])|(?:\.(?<path>[a-zA-Z]+[a-zA-Z0-9_]*(?:\[\d+\])*))*)?)?\}?';
120+
r'(?<!\\)\$\{?(?<value>(?<name>[a-zA-Z][a-zA-Z0-9_]*)((?<accessor>(?:\[\d+\])+)|(?:\.(?<path>[a-zA-Z]+[a-zA-Z0-9_]*(?:\[\d+\])*))*)?)?\}?';
121121

122122
/// Regex for [variablePathComposingPattern].
123123
final RegExp variablePathComposingRegex = RegExp(variablePathComposingPattern);

0 commit comments

Comments
 (0)