Champak Posted December 15, 2008 Share Posted December 15, 2008 (edited) I need to check the path if it contains some file extensions, but it isn't working. Why? I keep forgetting which way it works, so I tried two different ways, but neither one is working. StringInStr(".mp3,.wav,.avi", @GUI_DragFile) and StringInStr(@GUI_DragFile, ".mp3,.wav,.avi" ) I know there are a couple other options, but I really need to use StringInStr for this. Edited December 15, 2008 by Champak Link to comment Share on other sites More sharing options...
z0mgItsJohn Posted December 15, 2008 Share Posted December 15, 2008 (edited) Here's A Little Example.. Hope It Helps Code : ; Declare The String $String_1 = ('Test.Mp3') ; Check The String For .Mp3 $StringInStr_1 = StringInStr ($String_1, '.Mp3') ; ".Mp3" Can Be ".MP3" Etc.. Etc.. ; Declare The String.. $String_2 = ('Test.Au3') ; Check The String For .Au3 $StringInStr_2 = StringInStr ($String_2, '.Au3') ; ".Au3" Can Be ".AU#" Etc.. Etc.. ; Check Results If $StringInStr_1 <> '0' Then $Msg_1 = 'Contains ".Mp3"' Else $Msg_1 = 'Dose Not Contain ".Mp3"' EndIf If $StringInStr_2 <> '0' Then $Msg_2 = 'Contains ".Au3"' Else $Msg_2 = 'Dose Not Contains".Au3"' EndIf ; Display Results MsgBox ('0','Notice - Results','String 1 : "' & $String_1 & '" ' & $Msg_1 & @CRLF & 'String 2 : "' & $String_2 & '" ' & $Msg_2, '0') Random Smiles : - John Edited December 15, 2008 by John2006 Latest Projects :- New & Improved TCP Chat Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 15, 2008 Share Posted December 15, 2008 I need to check the path if it contains some file extensions, but it isn't working. Why? I keep forgetting which way it works, so I tried two different ways, but neither one is working. StringInStr(".mp3,.wav,.avi", @GUI_DragFile) and StringInStr(@GUI_DragFile, ".mp3,.wav,.avi" ) I know there are a couple other options, but I really need to use StringInStr for this. Somebody had to say it: StringRegExp(@GUI_DragFile, "\.(mp3|wav|avi)", 0) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Champak Posted December 15, 2008 Author Share Posted December 15, 2008 I'm glad you said it, thanks. Link to comment Share on other sites More sharing options...
trancexx Posted December 16, 2008 Share Posted December 16, 2008 Yes, but what if your file name is rental.avis.htm ...think quick! ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 16, 2008 Share Posted December 16, 2008 Yes, but what if your file name is rental.avis.htm ...think quick!The RegExp pattern I posted does not detect .htm at all. Since I did not specify finding the pattern at the end of the string, however, you could get a false match to something like "File.mp3.zip". Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
trancexx Posted December 16, 2008 Share Posted December 16, 2008 The RegExp pattern I posted does not detect .htm at all.Well, that was my point. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 16, 2008 Share Posted December 16, 2008 Well, that was my point.What was? Champak did not mention .htm at all. What are you talking about? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
trancexx Posted December 16, 2008 Share Posted December 16, 2008 What was? Champak did not mention .htm at all. What are you talking about? boundary thing... \b ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 16, 2008 Moderators Share Posted December 16, 2008 boundary thing... \bYou've obviously missed the entire concept of the original question. 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...
trancexx Posted December 16, 2008 Share Posted December 16, 2008 You've obviously missed the entire concept of the original question.possibly I was aiming to this: StringRegExp(@GUI_DragFile, "\.(mp3|wav|avi)\b", 0) What was the concept of the original question? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Champak Posted December 16, 2008 Author Share Posted December 16, 2008 Thanks tranncexx, not really needed now, but good to know for future stuff. This did pop an interest though. I see the possibility to replace a bunch of continuous "Or" conditions in my app with StringRegExp. So my question is, is it faster or less of a load to use the "Or" condition or StringRegExp? Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 16, 2008 Share Posted December 16, 2008 (edited) So my question is, is it faster or less of a load to use the "Or" condition or StringRegExp?Post the results after you test that... Edited December 16, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Champak Posted December 17, 2008 Author Share Posted December 17, 2008 Everybody is a comedian . I was looking if anyone had any general knowledge or insight on the subject, not necessarily for someone to test it out. But I went ahead and tested it out and per your request am reporting back the If Or condition is faster than StringRegExp. 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