logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
Hiking & Backpacking
New Age
Weight Loss
Tarot
California
Atheist / Agnostic
Southeast USA


dailyclick
All times in EST

Clairvoyance: 08:00 PM

Full Schedule
g
g ASP Site

BellaOnline's ASP Editor

g

Split ASP String Function


Are you trying to break a string up into smaller pieces? ASP provides an easy to use split function which lets you dice and slice a string.

Let's say you take in a sentence and want to put each word into a different variable. So you take in

NameStr = "Mr. John Smith"

Set up the array to hold the results with

Dim WordArray

then do the split, using a space as the split indicator

WordArray = Split(NameStr, " ")

Now WordArray(0) is equal to "Mr.", WordArray(1) is equal to "John" and WordArray(2) is equal to "Smith"! You can use various array functions and other string functions to work with these results.

There's of course a wealth of ways to use the split function. Many export programs will separate out their fields by a pipe symbol. A pipe is the vertical up-and-down line like this:

|

So you could do a split function looking for that pipe to break them out into their component pieces.

Be cautious that the field you're using to split really is only used for that split functionality. For example, you might think using a comma as a separator field is a wonderful idea. But what happens if there's actually a comma in one of the fields? Something like this:

Mr.,John,Doe,Boston
Mrs.Jane,Smith,Chicago
Miss,Julie,Roberts,Los Angeles
Mr.,Mark,Donner, Esq.,Miami

In that fourth row the man has a title after his last name, so he has his last name entered as

Donner, Esq.

But the split operation will see that comma and think it's a separator field.

That's why it's usually best to use a separator of a pipe (|) or something else quite unusual, so that you're sure it won't be showing up in the actual data stream as a normal value.

If you're working with strings be sure to look through the other ASP String Functions to learn how they work!

Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.
Add Split+ASP+String+Function to Twitter Add Split+ASP+String+Function to Facebook Add Split+ASP+String+Function to MySpace Add Split+ASP+String+Function to Del.icio.us Digg Split+ASP+String+Function Add Split+ASP+String+Function to Yahoo My Web Add Split+ASP+String+Function to Google Bookmarks Add Split+ASP+String+Function to Stumbleupon Add Split+ASP+String+Function to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2015 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.

g


g features
Regular Expression Pattern Matching

Saving Changes is Not Permitted error

Browser-Specific Code for IE and Netscape

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2015 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor