lolp1 Posted June 2, 2007 Share Posted June 2, 2007 Hello, I need to find a way to search for a string inside a string... I can't find the func in help file... My goal is to do something like this, search for the string inside a string, and if it is found act accordingly. Example: If $stringsearch > 1 then ; do what ever. (Assuming it = 1 if it finds the string) Link to comment Share on other sites More sharing options...
Bench Posted June 2, 2007 Share Posted June 2, 2007 Try function StringInStr. [right]Software is like sex - it's better when it's free. (Linus Torvalds)[/right] Link to comment Share on other sites More sharing options...
goldenix Posted November 17, 2007 Share Posted November 17, 2007 How comes if I use this help file code I get RESULT '10' ? shouldnt the result be 'ring' ? $result = StringInStr("I am a String", "ring") MsgBox(0, "Search result:", $result) My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
Nahuel Posted November 17, 2007 Share Posted November 17, 2007 These are the return values of StringInStr():Success: Returns the position of the substring. Failure: Returns 0 if substring not found. @Error 0 - Normal operation 1 - Occurrence was 0. Occurrence must be a positive or negative integer. Basically, it's just useful to know if the substring is in the string and where it is. Link to comment Share on other sites More sharing options...
wahoyaho Posted November 25, 2007 Share Posted November 25, 2007 Just do a $str = StringTrimLeft($str, $result) and you'll get ring. Link to comment Share on other sites More sharing options...
weaponx Posted November 25, 2007 Share Posted November 25, 2007 (edited) Just do a $str = StringTrimLeft($str, $result) and you'll get ring. That has nothing to do with searching a string. When you are searching like this and expecting the same value you entered to be returned that makes no sense, that value is already known. $result = StringInStr("I am a String", "ring") MsgBox(0, "Search result:", $result)oÝ÷ Øò¢èî²ÙÞyÖ¢^j{j·!Ê¢Øb±«¢+Ù%MÑÉ¥¹%¹MÑÈ ÅÕ½Ðí$´MÑÉ¥¹ÅÕ½Ðì°ÅÕ½ÐíÉ¥¹ÅÕ½Ðì¤Q¡¸(í ½)¹% Edited November 25, 2007 by weaponx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now