vbscript - Find the count and position of a character- VB script -


how find count of character in string , index value in vb script.
example "lion king of jungle" in example if n count 3 , position 3,10 , 18.

use regexp - in:

option explicit  dim s : s     = "lion king of jungle" dim c : c     = "n" dim r : set r = new regexp r.global  = true r.pattern = c dim ms : set ms = r.execute(s) wscript.echo "found", ms.count, "tokens of", c dim m each m in ms     wscript.echo m.firstindex + 1 next 

output:

cscript 29181557.vbs found 3 tokens of n 4 11 19 

the + 1 adjusts vbscript's 1 based string indices.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -