View previous topic :: View next topic |
Author |
Message |
yashpal
Joined: 18 Jan 2005 Posts: 2
|
Posted: Tue Jan 18, 2005 7:26 am Post subject: How TO Get substring |
|
|
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 |
|
|
administrator Site Admin
Joined: 01 Oct 2004 Posts: 183
|
Posted: Tue Jan 18, 2005 1:03 pm Post subject: |
|
|
Welcome to the ASPdev forums Yashpal
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 |
|
|
yashpal
Joined: 18 Jan 2005 Posts: 2
|
Posted: Wed Jan 19, 2005 5:01 am Post subject: |
|
|
Hi Peter,
Thanx for REPLY |
|
Back to top |
|
|
administrator Site Admin
Joined: 01 Oct 2004 Posts: 183
|
|
Back to top |
|
|
|
|
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
|