Re: I need a substring in ASP
|
Mable Henning |
|
5/30/2008 3:39:36 AM |
Hi Manvalo, 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
All the best! Post Comments |
|
Mable, Thanx for REPLY Manvalo Post Comments |
|
You're welcome Manvalo,
If you have any questions, let me know.
Post Comments |
|