* Counts unescaped occurrences of a character in a string. * A character is considered escaped if preceded by an odd number of backslashes.
(str: string, char: string)
| 27 | * A character is considered escaped if preceded by an odd number of backslashes. |
| 28 | */ |
| 29 | function countUnescapedChar(str: string, char: string): number { |
| 30 | let count = 0 |
| 31 | for (let i = 0; i < str.length; i++) { |
| 32 | if (str[i] === char && !isEscaped(str, i)) { |
| 33 | count++ |
| 34 | } |
| 35 | } |
| 36 | return count |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Checks if a string contains unescaped empty parentheses "()". |
no test coverage detected