We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › searching a String var
Page Index Toggle Pages: 1
searching a String var (Read 365 times)
searching a String var
Nov 4th, 2007, 2:21pm
 
hello all,

A bit of a noob question I'm afraid. I have just started playing around with processing and having fun with it though I am struggling with the following:

I want to search a String var for a certain word (a color for example) and run some code if this word is present in the string.

How do I go about searching a String var for a certain combination of characters? I have spent the last few hours poking around the reference part of the site and this forum but to no avail.

Soz if the answer is glaringly obvious! Thanks
Re: searching a String var
Reply #1 - Nov 4th, 2007, 2:49pm
 
Code:
int pos=myString.indexOf("red");
if(pos>=0)
{
doSomething();
}
Re: searching a String var
Reply #2 - Nov 4th, 2007, 3:22pm
 
of course. Thanks alot.
Page Index Toggle Pages: 1