Dracil 1 Posted May 20, 2010 Hello i need a little help. Lets say i have a string with "Army Troops : 1000 x" The number 1000 changes all the time, so how do i grab something by between the ":" and then "x" ? Thanks in advance 1 bikerbrooks reacted to this Share this post Link to post Share on other sites
enaiman 16 Posted May 20, 2010 StringSplit for ":" then get rid of anything but the number from the 2nd element. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example scriptwannabe "Unbeatable" Tic-Tac-ToePaper-Scissor-Rock ... try to beat it anyway :) Share this post Link to post Share on other sites
SmOke_N 211 Posted May 20, 2010 (edited) The search feature ( though not as good as it once was ) still works for simple things:http://www.autoitscript.com/forum/index.php?app=core&module=search§ion=search&do=quick_search&search_app=core&fromsearch=1Well that link is useless. Doesn't show the query or provide the link to the searched term.Anyway, if you looked at the "search" feature, typed in "text"+"between" and titles only, this would have been your first popup:http://www.autoitscript.com/forum/index.php?showtopic=103623&view=findpost&p=733863&hl=%22text%22+%22between%22&fromsearch=1That one does show the query, but it also has your answer. Edited May 20, 2010 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Share this post Link to post Share on other sites
Lee Bussy 0 Posted May 20, 2010 (edited) Something along these lines would get you close: ; Split string at the ":", return array $fields = StringSplit ( "Army Troops : 1000 x", ":") ; Remove the right most character (StringTrimRoght) and ; strip white space from the second element in the split ; array (StringStripWS) $yournumber = StringStripWS(StringTrimRight( $fields[2], 1 )) ... untested but it should be real close. EDIT: Doh, people answered as I was typing. Edited May 20, 2010 by Lee Bussy Share this post Link to post Share on other sites
Malkey 231 Posted May 20, 2010 Here is another four (4) methods for getting the text between two (2) search letters in a string. #include <String.au3> Local $sStr = "Army Troops : 1000 x" Local $iStart = StringInStr($sStr, ":") + 1 ConsoleWrite("StringMid = " & StringMid($sStr, $iStart, StringInStr($sStr, "x") - $iStart) & @CRLF) Local $aArray = _StringBetween($sStr, ":", "x") ConsoleWrite("_StringBetween = " & $aArray[0] & @CRLF) Local $aArrayRE = StringRegExp($sStr, ":(.*)x", 1) ConsoleWrite("StringRegExp = " & $aArrayRE[0] & @CRLF) ConsoleWrite("StringRegExpReplace = " & StringRegExpReplace($sStr, ".*:(.*)x.*", "\1") & @CRLF) Share this post Link to post Share on other sites
sahsanu 28 Posted May 21, 2010 (edited) Lets say i have a string with "Army Troops : 1000 x" The number 1000 changes all the time, so how do i grab something by between the ":" and then "x" ? Here we go with another possible solution ;-) Local $sStr = "Army Troops : 1000 x" Local $sResult=StringRegExpReplace($sStr,"(.*?)([0-9]{1,})(.*)","$2") ConsoleWrite('$sResult = ' & $sResult & @CRLF) I hope this helps. Have a nice day. sahsanu Edited May 21, 2010 by sahsanu Share this post Link to post Share on other sites