String Handling functions in ASPWe can use different functions of ASP ( using VBSCript ) to handle strings. Some common requirements like sending a string output to browser by using Response object or making a complex string search function there are functions to handle string. When we started our ASP scripts we stated with sending a simple string output to the browser.There are different functions used in handling strings like finding out the length of the string to manipulating string and splitting string to create an array etc. We will discuss these string functions with examples so we can use them as reference for developing our applications. Each tutorial here is focused on how to use one string function so you can read and understand there uses. The examples given here may not exactly match your requirements but these are developed keeping in mind give a basic understanding of the string functions and how they work. You can use the forum if you are facing any problem or a complex requirement you want to develop. Adding stringsHow to add two strings together to produce a third string? We can just display two strings by joining them using + ( plus ) symbol or using one & (ampersand ). These way two substrings can be added to crate one bigger string.String lengthWe can use len function to get the length of the string. This functions counts the chars and spaces used inside the string and returns a number. We can also find out the size of the function by using lenB function.Removing blank spaceWe can remove blank space present in a string at the starting or at the ending by using trim function. We can also specify ltrim or rtim to remove blank space from starting or ending of a string.Changing upper case letter to lower case and vise versaBy using Ucase we can change all lower case letters present in a sting to Upper case and same way use Lcase to change all Lower case letter to Upper case letter.Reversing a stringWe can print or change a string by reversing its order from ending to starting.String Compare in ASPWe can use strComp function in ASP to compare two string ( or substrings ) on various ways as required.Collecting part of a string from left right or middle areaWe can collect part of string from various locations ( starting ,ending or between ) by using left, right or mid functions in ASP.Matching string inside another stringWe can use InStr function to match a string inside another string. We can specify how the matching or compare type is to be done.Search and replace matching stringWe can search and then replace matching sting by using replace function in ASP. We can also specify the matching types based on which the matching will be carried out.Text line break to HTML line break by Replace functionReplacing vbcrlf to HTML line break to display in browser by using Replace function in ASPCreating array by breaking stringBy specifying a delimiter we can break a string and crate an array by using split function.Creating string by joining arrayWe can add all the elements of an array and create a string by using join function.
This article is written by plus2net.com team.
Be the first to post comment on this article : |
ASP functions to handle string Adding two or more strings in ASP Getting the size or length of the string by using len() function Removing blank space before and after a string using trim function Changing lower to upper or upper to lower case of text present inside a string Reversing a string variable by using StrReverse function Compare two strings in different ways by using StrComp function Collecting parts from Left , right and middle areas of a string Checking matching of a string inside another string using InStr function Searching and replacing strings inside another string using Replace function Creating arrays by splitting string using split() function Joining elements of an array to create a string variable Line Break by replacing text line break to html line break using Replace function |