RCLens Posted February 14, 2018 Share Posted February 14, 2018 (edited) Hello, I'd like to get the difference when I compare 2 strings. For instance: String1 = "toto123" String2 = "toto" Diff = "123" Thanks for your help Edited February 15, 2018 by RCLens Link to comment Share on other sites More sharing options...
SlackerAl Posted February 14, 2018 Share Posted February 14, 2018 You need to be very specific about how this should work: e.g. String1 = "toto123toto" String2 = "toto" gives? Have a look at regular expressions, these are probably the most efficient way to do this (helps to play here https://regex101.com/ ) check StringRegExp function. Otherwise look at StringInStr and the associate string functions. Problem solving step 1: Write a simple, self-contained, running, replicator of your problem. Link to comment Share on other sites More sharing options...
RCLens Posted February 14, 2018 Author Share Posted February 14, 2018 String1 = "toto123toto" String2 = "toto" Result = "123toto" Link to comment Share on other sites More sharing options...
SlackerAl Posted February 14, 2018 Share Posted February 14, 2018 (edited) Replace string does appear to work... I guess I should get another coffee.... Local $s1 = "abcddfg" Local $s2 = "cd" Local $out = StringReplace($s1,$s2,"",1) MsgBox(0,"test",$out) Edited February 14, 2018 by SlackerAl My laziness... Problem solving step 1: Write a simple, self-contained, running, replicator of your problem. Link to comment Share on other sites More sharing options...
jchd Posted February 15, 2018 Share Posted February 15, 2018 (edited) You need to strictly define what "difference" means to you in your context. For instance what is the "difference" in these cases ? Subject = "A1BC2D34EF" Test = "ABCDE" Subject = "ABCDE" Test = "A1BC2D34EF" Subject = "A1BC2D34EF" Test = "BCDEFGHIJK" a.s.o. Edited February 15, 2018 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
RCLens Posted February 15, 2018 Author Share Posted February 15, 2018 (edited) I used StringReplace function for that, thanks all Edited February 15, 2018 by RCLens 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