Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
String.charAt
String.elementAt
String.insertAt
String.removeAt
String.replaceAt
FUNCTION: String.find
String.find
(string, substring)
The
String.find
function searches a given string for the given substring and returns the index position of the first occurrence of the substring. If no match is made, then a -1 is returned.
This function treats a string as an array where the first index position is numbered zero and the last index position is the total length of the string minus one. The total length of the string can be found using the
String.length
function.
If either the
string
or
substring
parameters is the empty string "", or if both parameters are the empty string "", a -1 is returned.
The mandatory
string
parameter can be any string containing zero or more of any combination of characters and white spaces.
The mandatory
substring
parameter can be any string containing zero or more of any combination of characters and white spaces.
Code for FindExample.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1">
<p>
find example
</p>
<do type="accept">
<go href="FindExample.wmls#findfind()" />
</do>
</card>
<card id="card2">
<p>
string = $(strng)
<br />
substring = $(substring)
<br />
index = $(indexnum)
</p>
</card>
</wml>
Code for FindExample.wmls
extern function findfind()
{
var str = Dialogs.prompt("Enter a string", "");
var sub = Dialogs.prompt("Enter a substring", "");
var num =
String.find(str, sub)
;
WMLBrowser.setVar("strng", str);
WMLBrowser.setVar("substring", sub);
WMLBrowser.setVar("indexnum", num);
WMLBrowser.go("FindExample.wml#card2");
};
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information