ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How TO Get substring

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming
View previous topic :: View next topic  
Author Message
yashpal



Joined: 18 Jan 2005
Posts: 2

PostPosted: Tue Jan 18, 2005 7:26 am    Post subject: How TO Get substring Reply with quote

How can I get a substring "Finance" from a string like "Business and Finance" and "Telecom" from "IT And Telecom "

I want a substring from a string that start after "and"

I need it in ASP
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Tue Jan 18, 2005 1:03 pm    Post subject: Reply with quote

Welcome to the ASPdev forums Yashpal Smile

Here is the code you need:

Code:

<%

sString = "Business and Finance"

sString = Mid(sString, InStr(sString, "and") + 4)

Response.Write sString

%>


The InStr ASP/VBScript function will find the position of the first occurrence of one string within another. In this case the position of the string "and" within your main string. Then you add 4 to this number because the "and " string has 4 characters and you want to get the substring starting after "and ".

Finally you use the Mid VBScript function which gets a substring starting from the position specified in the second parameter, in this case InStr(sString, "and") + 4



Cheers,
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
yashpal



Joined: 18 Jan 2005
Posts: 2

PostPosted: Wed Jan 19, 2005 5:01 am    Post subject: Reply with quote

Hi Peter,

Thanx for REPLY
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Wed Jan 19, 2005 1:30 pm    Post subject: Reply with quote

You're welcome Smile

If you have any questions, let me know.


Cheers,
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial