[thelist] ASP Newbiw Question

aardvark roselli at earthlink.net
Sun Apr 14 20:44:01 CDT 2002


> From: "Olly Hodgson" <gnarly at punkass.com>
>
> Whats the syntax for "if variable contains string then" ?
>
> I got as far as
> <% if Request.ServerVariables("URL") = "Portfolio" then %>
> But I dont know how to do "contains" instead of "equals".

the instr() function ("in-string")...

IF instr(1,Request.ServerVariables("URL"),"Portfolio",1) > 0 THEN
	do stuff
END IF

it returns a number... if the number is 0, the thing you're looking for isn't in the
string... if the number is greater than 0, that's the position of the start of the
occurrence...

i can see that you're using it to parse out a directory name from a URL...  you
might want to take a look at an example of code that does a similar thing
(with a lot more string manipulation):

Breadcrumbs for Those Using ASP
http://evolt.org/article/list/17/4438/




More information about the thelist mailing list