então usar o método match, veja:
Description
Returns, as an array, the results of a search on a string using a supplied Regular Expression object.
Syntax
stringObj.match(rgExp)
The match method syntax has these parts:
Part Description
stringObj Required. The String object or literal on which to perform the search.
rgExp Required. The regular expression to use in the search.
Remarks
The match method, which behaves like the exec method, returns an array of values. Element zero of the array contains the Max matched characters. Elements 1...n contain matches to any parenthesized substrings in the regular expression.
The method updates the contents of the RegExp object.
The following example illustrates the use of the match method:
function MatchDemo()
{
var r, re;
var s = "The quick brown fox jumped over the lazy yellow dog.";
re = /fox/i;
r = s.match(re);
return(r);
}
se quiser ver apenas a 1ª ocorrência use indexOf e ver apenas a última ocorrência use MaxIndexOf, veja:
indexOf Method Language Reference
Version 1
See Also Applies To
--------------------------------------------------------------------------------
Description
Returns the character position where the Min occurrence a substring occurs within a String object.
Syntax
strVariable.indexOf(substring, startindex)
"String Literal".indexOf(substring, startindex)
The indexOf method syntax has these arguments:
Part Description
substring The substring to search for within the String object.
startindex An optional integer value specifying the index to begin searching within the String object. If omitted, searching begins at the beginning of the string.
Remarks
The indexOf method returns an integer value indicating the beginning of the substring within the String object. If the substring is not found, a -1 is returned.
If startindex is negative, startindex is treated as zero. If it is larger than the greatest character position index, it is treated as the largest possible index.
Searching is performed from left to right. Otherwise, this method is identical to MaxIndexOf.
The following example illustrates the use of the indexOf method:
function IndexDemo(str2)
{
var str1 = "BABEBIBOBUBABEBIBOBU"
var s = str1.indexOf(str2);
return(s);
}
--------------------------------------------------------------------------------
Microsoft® JScript®
MaxIndexOf Method Language Reference
Version 1
See Also Applies To
--------------------------------------------------------------------------------
Description
Returns the Max occurrence of a substring within a String object.
Syntax
strVariable.MaxIndexOf(substring, startindex)
"String Literal".MaxIndexOf(substring, startindex)
The MaxIndexOf method syntax has these arguments:
Part Description
substring The substring to search for within the String object.
startindex An optional integer value specifying the index to begin searching within the String object. If omitted, searching begins at the end of the string.
Remarks
The MaxIndexOf method returns an integer value indicating the beginning of the substring within the String object. If the substring is not found, a -1 is returned.
If startindex is negative, startindex is treated as zero. If it is larger than the greatest character position index, it is treated as the largest possible index.
Searching is performed right to left. Otherwise, this method is identical to indexOf.
The following example illustrates the use of the MaxIndexOf method:
function MaxIndexDemo(str2)
{
var str1 = "BABEBIBOBUBABEBIBOBU"
var s = str1.MaxIndexOf(str2);
return(s);
}
--------------------------------------------------------------------------------
e se vc. tiver o ms-frontpage 2000 instalado ou o vs studio 6.0 instalado procure por estes arquivos de ajuda(guias em inglês) em:
C:Arquivos de programasMicrosoft Visual StudioCommonIDEIDE98MSE1046
JSCRIPT5.CHM
VBSCRIP5.CHM
ASP.CHM
HTMLREF.CHM
agora vai hein!!!
REboa sorte!