(string: string)
| 23 | * @returns index or undefined |
| 24 | */ |
| 25 | export function getIndexIfArray(string: string) { |
| 26 | const indexRegex = /\[(\d+)\]/; |
| 27 | // Match the index |
| 28 | const match = string.match(indexRegex); |
| 29 | // Extract the index (number) |
| 30 | const index = match ? Number.parseInt(match[1]) : undefined; |
| 31 | return index; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Get the lowest level Zod type. |