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)
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
110110const 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] .
114114final 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.
119119const 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] .
123123final RegExp variablePathComposingRegex = RegExp (variablePathComposingPattern);
0 commit comments