Jump to content
Sign in to follow this  
Syed23

Help on String Compare

Recommended Posts

Syed23

Hi All,

I need a help on comparing 2 strings. I mean not comparing the length of the string the comparision should check whether both the strings are same or not? For Example, I have a file with 10 strings and now i am reading a registry and i want to compare that the string took from the registry and the string is there in the file are same. How can we do that ? Hope the StringCompare() function compares the length i may be wrong. which function will help for this? Please suggest me!


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites
wakillon

$_String1 = 'blah blah'

$_String2 = 'blah blah'

If $_String1 = $_String2 Then ConsoleWrite ( "strings are same" & @Crlf )

; use == for case sensitive

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
Syed23

I am an Idiot :).... i was thinking just all about but not this one :mellow:...

okay i gotta another question can you help me... i have 2 stringsss

$str1 = "Output folder: C:\Program Files\AutoIt3\SciTE"

$str2 = C:\Program Files\AutoIt3\SciTE"

now i wanted to check that $str2 is there in str1 or not how to do that ? will stringinstr() function help?


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites
wakillon

yes

$str1 = "Output folder: C:\Program Files\AutoIt3\SciTE"
$str2 = "C:\Program Files\AutoIt3\SciTE"
If StringInStr ( $str1, $str2  ) <> 0 Then ConsoleWrite ( "$str2 is a part of $str1" & @Crlf )

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
Syed23

yes

$str1 = "Output folder: C:\Program Files\AutoIt3\SciTE"
$str2 = "C:\Program Files\AutoIt3\SciTE"
If StringInStr ( $str1, $str2  ) <> 0 Then ConsoleWrite ( "$str2 is a part of $str1" & @Crlf )

It works as i expected. Thanks a lot...:mellow:

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

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  

×