pingpong24 Posted January 1, 2006 Share Posted January 1, 2006 (edited) Hi, I wrote this UDF because the standard funcations in autoit for doing this task is an hasle and also if someone elase ever wants to accomplish what i have done, they can search the forum and find this instead of wasting time like me. Func _GetStringMethod($String, $Starting, $Ending) $Result = StringRegExp($String,'('&$Starting&')([^'&$Ending&']*)',1) If @error = 0 And @extended Then Return $Result[1] EndFunc (not my code, its Smoke N code) Edited January 1, 2006 by pingpong24 NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
w0uter Posted January 1, 2006 Share Posted January 1, 2006 stringinstr would be better since the user now has to avoid using regexp operators like (\.{2,} My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 1, 2006 Moderators Share Posted January 1, 2006 (edited) He didn't like my example of the StringInStr(): http://www.autoitscript.com/forum/index.ph...ndpost&p=136062This would be another example to return the same result and probably throw less errors:Dim $String = 'gjsagjkajkgjalsgjls624623ajgkjlgkagajgas359283' Dim $Starting = 'jka' Dim $Ending = '62' MsgBox(0, "Test", _GetStringBetween($String, $Starting, $Ending)) Func _GetStringBetween($String, $Starting, $Ending) If StringInStr($String, $Starting) And StringInStr($String, $Ending) Then $StL = StringTrimLeft($String, StringInStr($String, $Starting) - 1) $SeL = StringLeft($StL, StringInStr($StL, $Ending) + 1) $StringBetween = StringTrimLeft(StringTrimRight($SeL, StringLen($Ending)), StringLen($Starting)) Return $StringBetween Else Return 0 EndIf EndFunc Edited January 2, 2006 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. Link to comment Share on other sites More sharing options...
w0uter Posted January 2, 2006 Share Posted January 2, 2006 or something like Func _StringBetween($s_String, $s_Start, $s_End = 0) $s_Start = StringInStr($s_String, $s_Start)+StringLen($s_Start) return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End)-$s_Start) EndFunc My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 2, 2006 Moderators Share Posted January 2, 2006 Nice one w0uter!! 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. Link to comment Share on other sites More sharing options...
erifash Posted January 2, 2006 Share Posted January 2, 2006 (edited) This might be useful:Func _StringParse( $sString, $sStart, $sEnd, $iOccurance = 0 ) Local $aA = StringSplit($sString, $sStart, 1), $aB = StringSplit($aA[_Test($iOccurance, _Test($iOccurance > 0, $iOccurance + 1, $aA[0] + $iOccurance + 1), $aA[0])], $sEnd, 1) Return $aB[1] EndFunc Func _Test( $bBool, $vTrue, $vFalse ) If $bBool Then Return $vTrue Return $vFalse EndFunc MsgBox(0, "expect c", _StringParse("[a][b][c][d][e][f]", "[", "]", -4)) ;positive occurance means search from left ;zero occurance means last occurance ;negative occurance means search from right EDIT: Updated with negative occurance. Edited January 2, 2006 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 2, 2006 Moderators Share Posted January 2, 2006 Ha!... Funny how people come to the same conclusion in different ways... Nice one erifash! 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. Link to comment Share on other sites More sharing options...
erifash Posted January 2, 2006 Share Posted January 2, 2006 stringinstr would be better since the user now has to avoid using regexp operators like (\.{2,} Why not use this function I wrote:Func _RegFormat( $str ) Local $a = StringSplit('\[]^:()?-.|{},*+', '') For $i = 1 to $a[0] $str = StringReplace($str, $a[$i], '\' & $a[$i]) Next Return $str EndFunc My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
w0uter Posted January 2, 2006 Share Posted January 2, 2006 since then you would need to include that function also (and b/c i forgot about it) My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll 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