Parse the following regex manually name(\[index\])?(\.field)?
| 29 | // Parse the following regex manually |
| 30 | // name(\[index\])?(\.field)? |
| 31 | VariableReference Parse(absl::string_view input) { |
| 32 | VariableReference ref; |
| 33 | auto start_index = input.find('['); |
| 34 | if (start_index != std::string::npos) { |
| 35 | auto end_index = input.rfind(']'); |
| 36 | if (end_index == std::string::npos) { |
| 37 | return ref; |
| 38 | } |
| 39 | ref.index = input.substr(start_index + 1, end_index - start_index - 1); |
| 40 | ref.name = input.substr(0, start_index); |
| 41 | ref.field = input.substr(end_index + 1); |
| 42 | } else { |
| 43 | auto dot = input.find('.'); |
| 44 | if (dot != std::string::npos) { |
| 45 | ref.name = input.substr(0, dot); |
| 46 | ref.field = input.substr(dot); |
| 47 | } else { |
| 48 | ref.name = input; |
| 49 | } |
| 50 | } |
| 51 | return ref; |
| 52 | } |
| 53 | |
| 54 | } // namespace variable_accessor_internal |
| 55 |