Jump to content

StrinInStr Help


Champak
 Share

Recommended Posts

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 by Champak
Link to comment
Share on other sites

Here's A Little Example.. Hope It Helps :mad:

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 : ;):):mad::)o:)

- John

Edited by John2006

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

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

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

  • Moderators

boundary thing... \b

You'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

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

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 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...