Sign in to follow this  
Followers 0
Champak

StrinInStr Help

14 posts in this topic

#1 ·  Posted (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 by Champak

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I'm glad you said it, thanks.

Share this post


Link to post
Share on other sites

Yes, but what if your file name is rental.avis.htm

...think quick!


♡♡♡

.

eMyvnE

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

The RegExp pattern I posted does not detect .htm at all.

Well, that was my point.

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

What was? Champak did not mention .htm at all. What are you talking about?

:)

boundary thing... \b

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#13 ·  Posted (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 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

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0