count number of characters in a string 
Author Message
 count number of characters in a string

What I am trying to do is evaluate a string and return the
number of times I encounter two characters...does any one
know of a method that can do this or would I have to
create my own function to loop through each character?
thanks in advance


Mon, 28 Jun 2004 03:15:37 GMT  
 count number of characters in a string
str   = "The quick red fox jumped over the lazy brown dog.";
re    = /[io]/g;
count = (m=str.match(re)) ? m.length : 0;
WScript.echo(count);

See "Introduction to Regular Expressions" in documentation.
http://download.microsoft.com/download/winscript56/Install/5.6/W982KM...

--
Everyone thinks of changing the world, but no one thinks of changing
himself. -Leo Tolstoy

=-=-=
Steve
-=-=-


Quote:
> What I am trying to do is evaluate a string and return the
> number of times I encounter two characters...does any one
> know of a method that can do this or would I have to
> create my own function to loop through each character?
> thanks in advance



Mon, 28 Jun 2004 05:05:34 GMT  
 count number of characters in a string
Yes, you need to create a loop function.

function srch(xChar){
var i, s, t = new Number();
s = "What I am trying to do is evaluate a string";
for(i = 0; i < s.length; i++){
 if(s.substring(i,i+1) == xChar) t++;
 }
return(t);

Quote:
}

> What I am trying to do is evaluate a string and return the
> number of times I encounter two characters...does any one
> know of a method that can do this or would I have to
> create my own function to loop through each character?
> thanks in advance



Mon, 28 Jun 2004 08:47:19 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Counting the number of occurrences of a character...

2. return the count of a particular character in a string

3. Number of characters in a string

4. Converting a number to a character string

5. Counting characters

6. procedure to count characters

7. Character Counting question

8. Page number count from a PostScript printer?

9. Counting number of sessions

10. Counting number of pages created

11. Counting number of pages

12. How to count number of pages in PS file

 

 
Powered by phpBB® Forum Software