View Full Version : search string function
bobcahill
June 7th, 2009, 03:34 PM
I need to be able to get the int returned on this. If I serach for any letter as a string I get the search function working right. If I run it like it is below I get back 0, which I should get 3. Any ideas
var testString:String = "the.rieh";
var getBack:int = testString.search(".")
trace(getBack);
SquirtGun
June 7th, 2009, 03:40 PM
Try using indexOf(); instead of search(".");
Your code would then be:
var testString:String = "the.rieh";
var getBack:int = testString.indexOf(".")
trace(getBack);
~squirt
bobcahill
June 7th, 2009, 03:41 PM
that works perfect. Thanks for the quick reply
JonnyR
June 7th, 2009, 04:58 PM
Incase you were wondering, the String.search() method is used for regular expressions (regexp) which is a sub language dedicated to working with Strings. You can find out more about RegEx and how to build your own from the Wikipedia article (http://en.wikipedia.org/wiki/Regular_Expressions).
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.