navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

check character in a string

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> check character in a string
Page: [1]
 
seth

 

Posts: 312
From: canada
Status: offline

 
check character in a string - 6/24/2007 4:08:37   
Hi, I was wondering how i can check a string to see how many underscores it contains.

I have two strings that have different number of underscores in them, one has 6 the other has 8. I need to do something base on the string's number of underscores. Thanks!
ou812

 

Posts: 1601
Joined: 1/5/2002
From: San Diego
Status: offline

 
RE: check character in a string - 6/24/2007 12:59:17   
I was thinking there must be an ASP function that does this, but I couldn't find one. The easiest way to do this, but probably not the most proper way is to split the string on the underscore into an array and then count the array. Something like:
Count1 = UBound(Split(String1, "_"))
Count2 = UBound(Split(String2, "_"))

If you're going to do this many times you could make a function and pass it the variables, otherwise just executing twice, once for each string is fine.

Otherwise, I guess you could walk through the sting character by character through a loop, using mid to pull out and compare each one against underscore. This might be the more proper way to do it, but it is more coding.

I think I would just go with the array, and waste a bit more resources.

_____________________________

-brian

EnterpriseDB: Enterprise-class relational database management system
PostgreSQL: The world's most advanced open source database

(in reply to seth)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> check character in a string
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts