Hi^^
I'm trying to count how many occurrences of a character (especially punctuation) are in a string.
I tried with this:
If I insert in the string(267) a "," or a "!" it seems to work and var(243) returns 1 occurrence.
But if var(267) = "test text?" and I use match(/?/g), then var(243) returns 0.
With other punctuation it returns even stanger numbers...
For example if I try to count how many "." or "..." are in a string it returns respectively 14 and 5 even if I put only 1 of them in the string...
It's clear I'm missing something but I can't understand what 😢
I'm trying to count how many occurrences of a character (especially punctuation) are in a string.
I tried with this:
Code:
$gameVariables.setValue(243, ($gameVariables.value(267).match(/,/g) || []).length)
If I insert in the string(267) a "," or a "!" it seems to work and var(243) returns 1 occurrence.
But if var(267) = "test text?" and I use match(/?/g), then var(243) returns 0.
With other punctuation it returns even stanger numbers...
For example if I try to count how many "." or "..." are in a string it returns respectively 14 and 5 even if I put only 1 of them in the string...
It's clear I'm missing something but I can't understand what 😢