Useful JavaScript/VBScript String Functions (Server side)
page 2 of 2
by Taewook Kang
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 18128/ 33

JavaScript Version

 

<SCRIPT LANGUAGE="JavaScript" RUNAT=Server>

/*
firStr function
Author: Taewook Kang ( txkang@wichita.edu )
Ex:
if you do...
fitStr( "Hello Kang! Nice to meet you!",5,10 )
it will return
Hello... you!

This function is very useful when you need to print long URLs.
*/

function fitStr( u,sideLength,offset )
{
     if ( u )
     {
          var curLen = u.length;
          return ( curLen >= offset ) ? u.substr( 0,sideLength ) + "..." + u.substr( curLen - sideLength,curLen ) : u;
     }      else
          return null;
}

/*
superTrim function
Author: Taewook Kang ( txkang@wichita.edu )

Ultimate trim function. It will trim all invisible
characters ( \n,\t.. etc ) before and after a string.
*/

function superTrim( s )
{
     return ( s ) ? s.replace( /^[\n\t\r ]+/,'' ).replace( /[\n\t\r ]+$/,'' ) : null;
}
</SCRIPT>

 


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-11 4:40:16 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search