User Defined Splice function

Returns all previous character up to the pattern match.



<script language="javascript1.1">
function splice(sPhrase,begin,end)
{
var length;
var i;
var sBuffer;
length=sPhrase.length;
sBuffer="";
for (i=0; i<length; i++)
{
if (i>=begin  &&  i<=end)
{
sBuffer=sBuffer+sPhrase.charAt(i);
}
}
return(sBuffer);
}
function ud_splice(sInputPhrase,sInputPattern)
{
var iFind;
var sResult;
var sPhrase;
var sPattern;
sPhrase=sInputPhrase;
sPattern=sInputPattern;
iFind=sPhrase.indexOf(sPattern);
if (iFind !=-1)
{
sResult=splice(sPhrase,0,iFind-1) ;
return(sResult);
}
}
</script>

You might also like...

Comments

David Nishimoto NishiSoft provides Part I of the Information Technology Project collaboration. Sign up and list your IT project tasks, assign task too friends, and get percent complete task. Part will include a wo...

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In theory, theory and practice are the same. In practice, they're not.”