1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0//EN">
6 <style type=
"text/css">
9 font-family: verdana
, sans-serif
;
29 text-decoration:underline
;
34 text-decoration: none
;
47 border-bottom-width:1px;
48 border-bottom-style:dotted
;
64 <table width=
"90%" border=
"0" cellspacing=
"1" cellpadding=
"5">
67 <big><tt>Global.String.prototype.count
(str)
</tt></big><br>
73 returns the amount of occurences of one string in another
<br><br>
87 <table width=
"90%" border=
"0" cellspacing=
"1" cellpadding=
"5">
89 <td>Sourcecode in /root/helma-
1.6.1/modules/core/String.js:
90 <pre><font color=
"#aaaaaa">528:
</font> String.prototype.count = function(str) {
91 <font color=
"#aaaaaa">529:
</font> var count =
0;
92 <font color=
"#aaaaaa">530:
</font> var offset =
0;
93 <font color=
"#aaaaaa">531:
</font> while ((offset = this.indexOf(str, offset))
> -
1) {
94 <font color=
"#aaaaaa">532:
</font> count +=
1;
95 <font color=
"#aaaaaa">533:
</font> offset +=
1;
96 <font color=
"#aaaaaa">534:
</font> }
97 <font color=
"#aaaaaa">535:
</font> return count;
98 <font color=
"#aaaaaa">536:
</font> }