I think the regex expression is not correct, for some reason. Alternatively, you can try to split the string into an array, and loop each element. Not sure about performance in this case
check the code i posted above. It has 2 words, but if you print found, it shows only the second word. The length is 1.
So, it starts counting on 1, but for some reason, your regex is skipping the first word. If you have only one word in the paragraph variable, the result is null.
I think your regex is excluding the first word.
I chenged the example in developer.mozilla.org/en-US/docs/W...
Can you share what are you trying to do with this code?
I need accurate counting. Code didn't count first word.
I think the regex expression is not correct, for some reason. Alternatively, you can try to split the string into an array, and loop each element. Not sure about performance in this case
It is correct. Counting Cyrillic words. But it starts counting from 0 not from 1.
check the code i posted above. It has 2 words, but if you print found, it shows only the second word. The length is 1.
So, it starts counting on 1, but for some reason, your regex is skipping the first word. If you have only one word in the paragraph variable, the result is null.
You are checking if space exists before word. Since first word doesn't have space before it, it fails to count it.
thepracticaldev.s3.amazonaws.com/i...