martin Posted May 19, 2009 Share Posted May 19, 2009 Martin your code isnt actually founding the chars in the stringDoesn't it? Can you give an example of it failing? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
oMBRa Posted May 19, 2009 Share Posted May 19, 2009 #include <Array.au3> $a = _StringInStrRandom ("MX0G2H883H7426288620TS", "G283H88620TS") _ArrayDisplay($a) Func _StringInStrRandom ($sSearchString, $sCharsString) Local $i, $Err = 0, $a Local $aS=stringsplit($sCharsString,''),$newS for $i = 1 to $aS[0] $newS &= ".*" & $aS[$i] Next $newS &= ".*" ConsoleWrite($newS & @CRLF) $a = StringRegExp($sSearchString,"(" & $newS & ")", 1) Return $a EndFunc; ==> _StringInStrRandom Link to comment Share on other sites More sharing options...
gcue Posted May 19, 2009 Author Share Posted May 19, 2009 Doesn't it? Can you give an example of it failing?its working so far.. curious to see if there is a case where it wouldnt work.. Link to comment Share on other sites More sharing options...
oMBRa Posted May 20, 2009 Share Posted May 20, 2009 I'm wrong, I misinterpreted Martin's code, I thought the OP wanted to find the string and not if it mateches or not, forgive me. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 20, 2009 Moderators Share Posted May 20, 2009 (edited) its working so far.. curious to see if there is a case where it wouldnt work.. Edit: Here, try this:MsgBox (0, "", _String_InStrRandom("MX0G2H883H7426288620TS?1539Z", "G283H88620TS?Z")) Func _String_InStrRandom($s_search_str, $s_char_str) Return StringRegExp($s_search_str, StringRegExpReplace(StringRegExpReplace( _ $s_char_str, "(.)", "\.*?$1"), "(\.\*\?)(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)", "$1\\$2")) EndFunc Edit2: Ok, I'm done! This one follows the same idea that Martin was doing... Seems to work, but added case sensitivity option:Func _String_InStrRandom($s_search_str, $s_char_str, $v_case = 0) Local $s_case = "(?i)" If $v_case Then $s_case = "" Return StringRegExp($s_search_str, $s_case & StringRegExpReplace($s_char_str, "(.)", "\.*?$1\.*?")) EndFuncOk Martin, I'll see your 10 lines, and make it 5 less (your turn ) Edited May 20, 2009 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...
martin Posted May 20, 2009 Share Posted May 20, 2009 I'm wrong, I misinterpreted Martin's code, I thought the OP wanted to find the string and not if it mateches or not, forgive me.No problem oMBRa, it doesn't seem like a terrible sin to me Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
gcue Posted September 17, 2009 Author Share Posted September 17, 2009 can anyone help me figure out what this would like like in a SQL query? (including case sensitivity) SELECT AssetTag,Model,SerialNumber FROM aInventoryInfo WHERE AssetTag LIKE ____ Thanks!!!!!!!! Maybe something like this MsgBox (0, "", _StringInStrRandom ("MX0G2H883H7426288620TS", "G283H88620TS")) Func _StringInStrRandom ($sSearchString, $sCharsString) Local $i, $Err = 0 Local $aS=stringsplit($sCharsString,''),$newS for $i = 1 to $aS[0] $newS &= ".*" & $aS[$i] Next $newS &= ".*" ConsoleWrite($newS & @CRLF) return StringRegExp($sSearchString,"(" & $newS & ")") EndFunc; ==> _StringInStrRandom Link to comment Share on other sites More sharing options...
gcue Posted September 17, 2009 Author Share Posted September 17, 2009 still not sure how to capture those instances when theres characters if there are middle characters between my string match.. bah! (this one only does before and after) "SELECT AssetTag,Model,SerialNumber FROM aInventoryInfo WHERE SerialNumber LIKE '%" & $serial & "%'" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 17, 2009 Moderators Share Posted September 17, 2009 What exactly does this have to do with RegEx? 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...
gcue Posted September 17, 2009 Author Share Posted September 17, 2009 trying to convert it to a _sqlite query.. heh sorry maybe shoulda started a new topic (i guess i figured id use the same topic since its the same query) 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