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

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -