The target string to search within.
The zero-based index of the character. Must satisfy 0 <= ind && ind <= s.length.
When ind === s.length, returns the position after the last character.
Optionalpretty: falseIf true, returns a human-readable string "row:col" (1-based).
If false or omitted, returns a tuple [row, col] (0-based).
pretty is false: A tuple [row, col] where both values are 0-based.pretty is true: A string in the format "row:col" where both values are 1-based.\n).\r) are treated as regular characters, not line breaks.const text = "hello\nworld";
getRowCol(text, 0); // [0, 0] - 'h' at row 0, col 0
getRowCol(text, 5); // [0, 5] - '\n' at row 0, col 5
getRowCol(text, 6); // [1, 0] - 'w' at row 1, col 0
getRowCol(text, 11); // [1, 5] - position after 'd'
getRowCol(text, 6, true); // "2:1" - 'w' at row 2, col 1 (1-based)
Get the row and column position of a character in a string.
The target string to search within.
The zero-based index of the character. Must satisfy 0 <= ind && ind <= s.length.
When ind === s.length, returns the position after the last character.
If true, returns a human-readable string "row:col" (1-based).
If false or omitted, returns a tuple [row, col] (0-based).
pretty is false: A tuple [row, col] where both values are 0-based.pretty is true: A string in the format "row:col" where both values are 1-based.\n).\r) are treated as regular characters, not line breaks.const text = "hello\nworld";
getRowCol(text, 0); // [0, 0] - 'h' at row 0, col 0
getRowCol(text, 5); // [0, 5] - '\n' at row 0, col 5
getRowCol(text, 6); // [1, 0] - 'w' at row 1, col 0
getRowCol(text, 11); // [1, 5] - position after 'd'
getRowCol(text, 6, true); // "2:1" - 'w' at row 2, col 1 (1-based)
Get the row and column position of a character in a string.