AutID Posted October 25, 2013 Share Posted October 25, 2013 (edited) Hello,Edit: #post 3 Edited October 25, 2013 by AutID https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
gruntydatsun Posted October 25, 2013 Share Posted October 25, 2013 (edited) the first one removes all vertical white space in front of any character other than a [ Edited October 25, 2013 by gruntydatsun Link to comment Share on other sites More sharing options...
AutID Posted October 25, 2013 Author Share Posted October 25, 2013 (edited) That much i understood after reading it some hours.This is my script.expandcollapse popup#include <Array.au3> Global $STEMPMESS, $STEMPUSER Local $test = 0 Local $SLINES = "[04:27:26] <test1> ] <p2ff>" & @LF & _ "[04:27:36] <test1> par211233123azit" & @LF & _ "[04:27:36] <test1> par2112341243123azit" & @LF & _ "[04:27:39] <test1> ] <pf3f>" & @LF & _ "[04:27:55] <test2> yukiii" & @LF & _ "[04:28:23] <test2> ] ok i dont " & @LF & _ "[04:27:39] <test3> <test> par213123azit<test> par213123azit " & @LF & _ "[04:27:39] <test3> parazit123" $SLINES = StringRegExpReplace($SLINES, "(\v+)([^\[])", "$2") Local $ALINES = StringRegExp($SLINES, "(? :([^\v]+)(?:\v+|$))", 3) _ArrayDisplay($ALINES) If IsArray($ALINES) Then Local $SRES = "" For $I = 0 To UBound($ALINES) - 1 $test = $test + 1 $STEMPMESS = StringRegExpReplace($ALINES[$I], "(?:^.*?>|.*?\])(\h*.*?\h*)((\].*$)|$)", "$1") For $J = 0 To UBound($ALINES) - 1 If (StringInStr($ALINES[$I], "[System Message]") = 0) And ($I <> $J) And (StringCompare($STEMPMESS, StringRegExpReplace($ALINES[$J], "(?:^.*?>|.*?\])(\h*.*?\h*)((\].*$)|$)", "$1"), 1) = 0) Then $STEMPUSER = StringRegExpReplace($ALINES[$I], "(?:\[.*?<)(.*?)>.*$", "$1") If $STEMPUSER == StringRegExpReplace($ALINES[$J], "(?:\[.*?<)(.*?)>.*$", "$1") Then If $I < $J Then If $J - $I < 4 Then $SRES &= StringFormat('Line %3d/ is: "%s"\n', $I + 1, $ALINES[$I]) & StringFormat('Line %3d/ is: "%s"\n', $J + 1, $ALINES[$J]) ExitLoop Else $INUMUSERS = 0 For $K = ($I + 1) To ($J - 1) If $STEMPUSER == StringRegExpReplace($ALINES[$K], "(?:\[.*?<)(.*?)>.*$", "$1") Then $INUMUSERS += 1 If $INUMUSERS = 3 Then ExitLoop 2 EndIf Next $SRES &= StringFormat('Line %3d/ is: "%s"\n', $I + 1, $ALINES[$I]) & StringFormat('Line %3d/ is: "%s"\n', $J + 1, $ALINES[$J]) EndIf EndIf EndIf EndIf Next Next If $SRES = "" Then ConsoleWrite("No user found" & @CRLF & @CRLF & $test & " lines checked." & @CRLF) Else ConsoleWrite(@CRLF & @CRLF & "Lines " & @CRLF & $SRES & @LF) EndIf Else MsgBox(64, "Attention", $SWINTITLE & " has no lines present.", 2) EndIfWhy this is telling me that the 1st and the 4th line are the same?I think my problem is where i strip out the messages to compare.This patern myst be wrong.$STEMPMESS = StringRegExpReplace($ALINES[$I], "(?:^.*?>|.*?\])(\h*.*?\h*)((\].*$)|$)", "$1") Edited October 25, 2013 by AutID https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
jchd Posted October 25, 2013 Share Posted October 25, 2013 Please make it clear about what you expect and where, much simpler (one regexp only) and self-contained. 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...
AutID Posted October 25, 2013 Author Share Posted October 25, 2013 Bonjour, What i am doing is; i am checking the messages each user send. If there are messages that are exactly the same then i get the user of the messages. If between the two lines that are the same the user hasnt already written something different then i am displaying it in a msgbox as a spam and some other staff... The problem is that it is giving me the 1st and the 4th lines are exactly the same which is not true. The error is in the $STEMPMESS @replace. https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 25, 2013 Moderators Share Posted October 25, 2013 (edited) AutId,I am afraid that is a clear as mud to me. Some questions: - 1. How do you tell which user sent the message? Is it the <test#> section in the lines you posted above?- 2. You say you want to detect exact copies of messages - there are no exact copies in the lines you posted, other than in this one:"[04:27:39] <test3> <test> par213123azit<test> par213123azitwhich is significantly different in format to all the others. Is that indeed what you looking for? Or could the copies be on different lines?M23 Edited October 25, 2013 by Melba23 Typo  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
AutID Posted October 25, 2013 Author Share Posted October 25, 2013 Melba thats my problem. Normally it should return false and say that there are no same message. But it returns the 1st and the 4th lines as same messages which means my stringregexpreplace for the message is wrong... The lines are fomated like this, first is the time in the [...] then is the user <...> and then is the message... https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 26, 2013 Moderators Share Posted October 26, 2013 AutID,When I run the code you posted I just get a an error from this line:Local $ALINES = StringRegExp($SLINES, "(? :([^\v]+)(?:\v+|$))", 3)telling me that the pattern is bad - so no array is generated and the main part of the script is bypassed. Help us to help you by explaining what your script is doing as it moves along - at the moment we need to guess about your logic and the role of the multiple RegEx lines. Personally I am not prepared to waste my brain cells trying to decipher all your RegExes - I have enough trouble building my own and I am not prepared to try and work through someone elses. So how about you add some comments telling us what is happening (or suppposed to happen) as the script runs - then we might be able to offer some focused help. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 26, 2013 Share Posted October 26, 2013 (edited) @M23, Local $ALINES = StringRegExp($SLINES, "(? :([^\v]+)(?:\v+|$))", 3) is supposed to be Local $ALINES = StringRegExp($SLINES, "(?:([^\v]+)(?:\v+|$))", 3) . . . @AutID you are only comparing the message part, irrespective of the user and time. Right ? Plus, is the part underlined, the message? [04:27:26] <test1> ] <p2ff> [04:27:36] <test1> par211233123azit [04:27:36] <test1> par2112341243123azit [04:27:39] <test1> ] <pf3f> [04:27:55] <test2> yukiii [04:28:23] <test2> ] ok i dont [04:27:39] <test3> <test> par213123azit<test> par213123azit [04:27:39] <test3> parazit123 Note: the space after the username isn't included as per it. if the above two hold true, the following may help expandcollapse popup#include <Array.au3> #include <Misc.au3> Global $STEMPMESS, $STEMPUSER Local $test = 0 Local $SLINES = "[04:27:26] <test1> ] <p2ff>" & @LF & _ "[04:27:36] <test1> par211233123azit" & @LF & _ "[04:27:36] <test1> par2112341243123azit" & @LF & _ "[04:27:39] <test1> ] <pf3f>" & @LF & _ "[04:27:55] <test2> yukiii" & @LF & _ "[04:28:23] <test2> ] ok i dont " & @LF & _ "[04:28:23] <test2> yukiii " & @LF & _ "[04:27:39] <test3> <test> par213123azit<test> par213123azit " & @LF & _ "[04:27:39] <test3> ] <p2ff>" & @LF & _ "[04:27:39] <test3> parazit123" & @LF & _ "[04:27:42] <test7> parazit123" $SLINES = StringRegExpReplace($SLINES, "(\v+)([^\[])", "$2") Local $ALINES = StringRegExp($SLINES, "(?:([^\v]+)(?:\v+|$))", 3) _ArrayDisplay($ALINES) Local $aMESSAGES = StringRegExp($SLINES, "(?m)^(?:\[.*?<.*?> )(.*?)$", 3) _ArrayDisplay($aMESSAGES) ConsoleWrite("Comparing Messages" & @CRLF) Local $aTemp, $s_Ret ;Now lets compare the messages For $i = 0 To UBound($aMESSAGES)-1 $aTemp = _ArrayFindAll($aMESSAGES, $aMESSAGES[$i]) If @error Or UBound($aTemp) = 1 Then ContinueLoop $s_Ret &= "->" & $i & " line's message matches with " For $n = 0 To UBound($aTemp) -1 If $aTemp[$n] > $i Then $s_Ret &= $aTemp[$n] & ", " Next $s_Ret = _Iif(StringRight($s_Ret,2) = ", ", StringTrimRight($s_Ret, 2) & " line's message. ie " & $aMESSAGES[$i] & @CRLF, StringRegExpReplace($s_Ret, "(?m)(.*)\v+.*$", "$1")) Next ConsoleWrite($s_Ret) Edited October 26, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
mikell Posted October 26, 2013 Share Posted October 26, 2013 And the guess play is started, right ? Link to comment Share on other sites More sharing options...
AutID Posted October 26, 2013 Author Share Posted October 26, 2013 This is going from bad to worst... Sorry for that.Let me explain better. I added comment lines to the script so you can understandexpandcollapse popup#include <Array.au3> Global $SWINTITLE = "acmm_client" Global $STEMPMESS, $STEMPUSER Local $test = 0 Local $SLINES = "[04:27:26] <user1> ] message1" & @LF & _ "[04:27:36] <user1> message123" & @LF & _ "[04:27:36] <user1> message543" & @LF & _ "[04:27:39] <user1> ] message3312" & @LF & _ "[04:27:55] <user2> message2" & @LF & _ ;TEXT "[04:28:23] <user2> ] message4 " & @LF & _ "[04:27:39] <user3> message8 " & @LF & _ "[04:27:39] <user3> message5" $SLINES = StringRegExpReplace($SLINES, "(\v+)([^\[])", "$2") ;Remove vertical spaces exept [ Local $ALINES = StringRegExp($SLINES, "(?:([^\v]+)(?:\v+|$))", 3) ;Return the valid array _ArrayDisplay($ALINES) If IsArray($ALINES) Then Local $SRES = "" For $I = 0 To UBound($ALINES) - 1 ; Count lines $test = $test + 1 $STEMPMESS = StringRegExpReplace($ALINES[$I], "(?:^.*?>|.*?\])(\h*.*?\h*)((\].*$)|$)", "$1") ;Get the message of each line For $J = 0 To UBound($ALINES) - 1 ;Count lines If (StringInStr($ALINES[$I], "[System Message]") = 0) And ($I <> $J) And (StringCompare($STEMPMESS, StringRegExpReplace($ALINES[$J], "(?:^.*?>|.*?\])(\h*.*?\h*)((\].*$)|$)", "$1"), 1) = 0) Then ;If [System Message] doesn't exists between the two same linece, if there are two different lines with the same message, If the two messages are exactly the same $STEMPUSER = StringRegExpReplace($ALINES[$I], "(?:\[.*?<)(.*?)>.*$", "$1") ;Then get the users of the messages that are exactly the same If $STEMPUSER == StringRegExpReplace($ALINES[$J], "(?:\[.*?<)(.*?)>.*$", "$1") Then ;If the two users are the same, means that the user is 1 and is sending the same message twice If $I < $J Then If $J - $I < 4 Then ;If there are less than 4 lines between the two same messages $SRES &= StringFormat('Line %3d/ is: "%s"\n', $I + 1, $ALINES[$I]) & StringFormat('Line %3d/ is: "%s"\n', $J + 1, $ALINES[$J]) ;Get the line ExitLoop Else $INUMUSERS = 0 For $K = ($I + 1) To ($J - 1) ;Count lines between the 2 same messages If $STEMPUSER == StringRegExpReplace($ALINES[$K], "(?:\[.*?<)(.*?)>.*$", "$1") Then $INUMUSERS += 1 ;Count the user If $INUMUSERS = 3 Then ;If the user has sent the different messages between the two same messages then dont get the line. ExitLoop 2 EndIf Next $SRES &= StringFormat('Line %3d/ is: "%s"\n', $I + 1, $ALINES[$I]) & StringFormat('Line %3d/ is: "%s"\n', $J + 1, $ALINES[$J]) EndIf EndIf EndIf EndIf Next Next If $SRES = "" Then ConsoleWrite("No user found" & @CRLF & @CRLF & $test & " lines checked." & @CRLF) Else ConsoleWrite(@CRLF & @CRLF & "Lines " & @CRLF & $SRES & @LF) EndIf Else MsgBox(64, "Attention", $SWINTITLE & " has no lines present.", 2) EndIf1st: Remove vertical spaces besides [2ond: Return a valid array3rd: Count the lines4th: Get message of each line5th: Count lines again6th: Get the messages again and check if they are in different lines, if the text "[system Message]" exists between the two same lines and if the two messages are exactly the same7th: If 6th is true then get the user of the two same messages8th: Check if the two same messages have the same user which means that the user is 1 and has sent the same message twice9th: If 8th is true then check if there are less than 4 different lines with the same user between the two same messages https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
AutID Posted October 27, 2013 Author Share Posted October 27, 2013 Well got that thing working. As i was saying my patern for the message was wrong. I used the patern @PhoenixXL used for the message and it is working Thank you guys and sorry for the troubles...expandcollapse popup#include <Array.au3> Global $SWINTITLE = "acmm_client" Global $STEMPMESS, $STEMPUSER Local $test = 0 Local $SLINES = "[04:27:26] <user1> ] message1" & @LF & _ "[04:27:36] <user1> message123" & @LF & _ "[04:27:36] <user1> message543" & @LF & _ "[04:27:39] <user1> ] message1" & @LF & _ "[04:27:55] <user2> message2" & @LF & _ ;TEXT "[04:28:23] <user2> ] message4 " & @LF & _ "[04:27:39] <user3> message8 " & @LF & _ "[04:27:39] <user3> message5" $SLINES = StringRegExpReplace($SLINES, "(\v+)([^\[])", "$2") ;Remove vertical spaces exept [ Local $ALINES = StringRegExp($SLINES, "(?:([^\v]+)(?:\v+|$))", 3) ;Return the valid array If IsArray($ALINES) Then Local $SRES = "" For $I = 0 To UBound($ALINES) - 1 ; Count lines $test = $test + 1 $STEMPMESS = StringRegExpReplace($ALINES[$I], "(?m)^(?:\[.*?<.*?> )(.*?)$", "$1") ;Get the message of each line For $J = 0 To UBound($ALINES) - 1 ;Count lines If (StringInStr($ALINES[$I], "[System Message]") = 0) And ($I <> $J) And (StringCompare($STEMPMESS, StringRegExpReplace($ALINES[$J], "(?m)^(?:\[.*?<.*?> )(.*?)$", "$1"), 1) = 0) Then ;If [System Message] doesn't exists between the two same linece, if there are two different lines with the same message, If the two messages are exactly the same $STEMPUSER = StringRegExpReplace($ALINES[$I], "(?:\[.*?<)(.*?)>.*$", "$1") ;Then get the users of the messages that are exactly the same If $STEMPUSER == StringRegExpReplace($ALINES[$J], "(?:\[.*?<)(.*?)>.*$", "$1") Then ;If the two users are the same, means that the user is 1 and is sending the same message twice If $I < $J Then If $J - $I < 4 Then ;If there are less than 4 lines between the two same messages $SRES &= StringFormat('Line %3d/ is: "%s"\n', $I + 1, $ALINES[$I]) & StringFormat('Line %3d/ is: "%s"\n', $J + 1, $ALINES[$J]) ;Get the line ExitLoop Else $INUMUSERS = 0 For $K = ($I + 1) To ($J - 1) ;Count lines between the 2 same messages If $STEMPUSER == StringRegExpReplace($ALINES[$K], "(?:\[.*?<)(.*?)>.*$", "$1") Then $INUMUSERS += 1 ;Count the user If $INUMUSERS = 3 Then ;If the user has sent the different messages between the two same messages then dont get the line. ExitLoop 2 EndIf Next $SRES &= StringFormat('Line %3d/ is: "%s"\n', $I + 1, $ALINES[$I]) & StringFormat('Line %3d/ is: "%s"\n', $J + 1, $ALINES[$J]) EndIf EndIf EndIf EndIf Next Next If $SRES = "" Then ConsoleWrite("No user found" & @CRLF & @CRLF & $test & " lines checked." & @CRLF) Else ConsoleWrite(@CRLF & @CRLF & "Lines " & @CRLF & $SRES & @LF) EndIf Else MsgBox(64, "Attention", $SWINTITLE & " has no lines present.", 2) EndIf https://iblockify.wordpress.com/ 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