[javascript-dev] Searching through a string
lists at zdomain.net
lists at zdomain.net
Sun Nov 4 20:36:23 MST 2007
- Previous message: [javascript-dev] Searching through a string
- Next message: [javascript-dev] js disobeys law of cause and effect
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks for the reply, Wesley. I was able to get it to work, thanks in
no small part to using your observation!
Here is the working code:
----BEGIN SCRIPT----
function anything()
{
var pattern=/sleep/;
inputString = arrayfromargs(messagename, arguments);
post("LENGTH IS " + inputString.length);
post(inputString);
for (var i=0; i<inputString.length; i++){
if (inputString[i].match(pattern)){
outputString="There it is!";
}
else{
outputString = "Sorry, not here!";
}
}
bang();
}
----END SCRIPT----
Best,
-R
Quoting Wesley Smith <wesley.hoke at gmail.com>:
> inputString is an array in your code. Perhaps you need to do
> inputString[i].search(pattern).
>
> wes
>
> On 11/4/07, lists at zdomain.net <lists at zdomain.net> wrote:
>> Hi all:
>>
>> I've been trying to get the following search script to work, but I get
>> "inputString.search is not a function". What am I doing wrong?
>>
>> ----BEGIN SCRIPT----
>> function anything()
>> {
>> var pattern=/href/;
>> inputString = arrayfromargs(messagename, arguments);
>> post("LENGTH IS " + inputString.length);
>> for (var i=0; i<inputString.length; i++){
>> if (inputString.search(pattern)){
>> outputString="There it is!";
>> }
>> else{
>> outputString = "Sorry, not here!";
>> }
>> }
>> bang();
>> }
>> ----END SCRIPT----
>>
>> Thanks in advance,
>>
>> -R
>> _______________________________________________
>> javascript-dev mailing list
>> javascript-dev at cycling74.com
>> http://www.cycling74.com/mailman/listinfo/javascript-dev
>>
> _______________________________________________
> javascript-dev mailing list
> javascript-dev at cycling74.com
> http://www.cycling74.com/mailman/listinfo/javascript-dev
>
- Previous message: [javascript-dev] Searching through a string
- Next message: [javascript-dev] js disobeys law of cause and effect
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
