Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2005, 05:38 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default string split by :

My original string:

ADULT NETNET:134,GROSS:169,TAX:69.70,ADDON:35,WKEND:0,FU EL:0,MRKUP:0,AGYMRKUP:0,FEE:0,TTL:273.70,CID/CTC: 39/IT5AFKLE


My code:

<%
dim arrStr
dim theStr

theStr = xmldoc.documentelement.selectnodes("dataElementsMa ster").item(0).selectnodes("dataElementsIndiv").it em(2).selectnodes("miscellaneousRemarks").item(0). selectnodes("remarks").item(0).selectnodes("freete xt").item(0).text
'response.write "theStr = " & theStr & "<br>"
arrStr = Split(theStr,",")

for i=0 to Ubound(arrStr)
     response.write "arrStr = " & (arrStr(i)) & "<br>"
next
%>

My output:

arrStr = ADULT NETNET:134
arrStr = GROSS:169
arrStr = TAX:69.70
arrStr = ADDON:35
arrStr = WKEND:0
arrStr = FUEL:0
arrStr = MRKUP:0
arrStr = AGYMRKUP:0
arrStr = FEE:0
arrStr = TTL:273.70
arrStr = CID/CTC: 39/IT5AFKLE

How can i split the string up even further to get just what comes after the ':'

Thanks.

Picco


www.crmpicco.co.uk
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old February 10th, 2005, 06:25 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

For each array element string,extract string after : and store it in one more array inside the loop.




 
Old February 10th, 2005, 06:26 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Picco,

I would use a regular expression - well worth looking into if you're going to do much in the way of string manipulation. Try this...
Code:
Dim expr: Set expr = New RegExp
expr.Pattern = "[^:]*:([^,]*),?"
expr.Global = True
Dim match, matches
Set matches = expr.Execute(theStr)
For Each match In matches
    response.write "item = " & match.SubMatches(0) & "<br />"
Next
Set matches = Nothing
Set expr = Nothing
HTH,

Chris

 
Old February 10th, 2005, 07:49 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

that works excellent - thank you very much mate

www.crmpicco.co.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to split string krevathi1912 Access VBA 10 September 6th, 2007 02:21 AM
string split vidhya XSLT 1 August 10th, 2005 04:53 AM
How to split a string lily611 General .NET 5 March 18th, 2005 01:16 PM
String.Split bbhill General .NET 2 April 10th, 2004 05:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.