Jump to content

=== && ==


desithugg

Recommended Posts

Hi, I'm trying to convert a function someone wrote for me in PHP a while back which returns the text between two objects in an array.

For example.

text="[saad]hello[/saad]sffsad90aa89a8da[saad]bye[/saad]";
found=findText("[saad]","[/saad]",text);
//found[0] would return hello
//found[1] would return bye

Below is what I've wrote, but it doesn't seem to be working. I believe the problem is the !==, anybody else have a clue?

function mySubStr(strP,startP,endP){
   if(endP==0)
      endP=strP.length-startP;
   return strP.substr(startP,endP);
}
function myIndexOf(strP,searchP){
   return strP.indexOf(searchP);
}
function findText(openPin,endPin,hayStack){
   var textFound = new Array();
   openPin  = openPin.toLowerCase();
   endPin   = endPin.toLowerCase();
   var opLength = opLength.length;
   var epLength = epLength.length;
   var hsCheck  = hsCheck.toLowerCase();
   do{
      opPos=myIndexOf(hsCheck,openPin);
      if(opPos!==false){
         epPos=myIndexOf(mySubStr(hsCheck,opPos+opLength,0),endP);
         if(epPos!==false){
            textFound[] = mySubStr(hayStack,opPos+opLength,epPos);
            hayStack    = mySubStr(hayStack,opPos+opLength+epPos+epLength,0);
            hsCheck     = hayStack.toLowerCase();
         }
      }
   }while((opPos!==false) && (epPos!==false));
   return textFound;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.