kimurtus Posted July 20, 2011 Share Posted July 20, 2011 with this text data in line Result: 2bfbab92 rejected [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)] is there a way to detect in the text "Result: 2bfbab92 rejected" and text "Result: 2bfbab92 accepted?" with the code i tried to build, both StringRegExp respond with detection, any alternative with StringRegExp to work arround these and detect acepted or rejected text without the [0 Accepted] [1 Rejected] misleading the output? or will StringRegExp not work for what i intend it to work for? $line ='Result: 2bfbab92 rejected [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' if StringRegExp($line, '(?i)Result: (.*?) accepted(?i)') = 1 then consolewrite ('+Result Acepted'&@lf) EndIf if StringRegExp($line, '(?i)Result: (.*?) rejected(?i)') = 1 Then consolewrite ('!Result Rejected'&@lf) EndIf Link to comment Share on other sites More sharing options...
martin Posted July 20, 2011 Share Posted July 20, 2011 with this text data in line Result: 2bfbab92 rejected [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)] is there a way to detect in the text "Result: 2bfbab92 rejected" and text "Result: 2bfbab92 accepted?" with the code i tried to build, both StringRegExp respond with detection, any alternative with StringRegExp to work arround these and detect acepted or rejected text without the [0 Accepted] [1 Rejected] misleading the output? or will StringRegExp not work for what i intend it to work for? $line ='Result: 2bfbab92 rejected [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' if StringRegExp($line, '(?i)Result: (.*?) accepted(?i)') = 1 then consolewrite ('+Result Acepted'&@lf) EndIf if StringRegExp($line, '(?i)Result: (.*?) rejected(?i)') = 1 Then consolewrite ('!Result Rejected'&@lf) EndIf if there is always a '[' after the accepted or rejected then this should work $line ='Result: 2bfbab92 accepted [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' if StringRegExp($line, '(?i)Result:(.*)accepted( *)\[') = 1 then consolewrite ('+Result Acepted'&@lf) EndIf if StringRegExp($line, '(?i)Result:(.*)rejected( *)\[') = 1 Then consolewrite ('!Result Rejected'&@lf) EndIf Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
kimurtus Posted July 20, 2011 Author Share Posted July 20, 2011 hi martin it usualy have a space or a @cr after accepted or rejected word, but testing arround with your recomendation i come up with this, not sure if it is the best way but it works now thank you, $line ='[19/07/2011 22:01:15] Result: 2bfbab92 accepted [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' ;~ $line ='[19/07/2011 22:01:15] Result: 2bfbab92 accepted'&@CR&'[435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' ;~ $line ='[19/07/2011 22:01:15] Result: 2bfbab92 rejected [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' ;~ $line ='[19/07/2011 22:01:15] Result: 2bfbab92 rejected'&@CR&'[435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' if StringRegExp($line, '(?i)Result:(.*)accepted( *) ') = 1 or StringRegExp($line, '(?i)Result:(.*)accepted( *)'&@cr) = 1 then consolewrite ('+Result Acepted'&@lf) EndIf if StringRegExp($line, '(?i)Result:(.*)rejected( *) ') = 1 or StringRegExp($line, '(?i)Result:(.*)rejected( *)'&@cr) = 1 Then consolewrite ('!Result Rejected'&@lf) EndIf Link to comment Share on other sites More sharing options...
martin Posted July 21, 2011 Share Posted July 21, 2011 hi martin it usualy have a space or a @cr after accepted or rejected word, but testing arround with your recomendation i come up with this, not sure if it is the best way but it works now thank you, $line ='[19/07/2011 22:01:15] Result: 2bfbab92 accepted [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' ;~ $line ='[19/07/2011 22:01:15] Result: 2bfbab92 accepted'&@CR&'[435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' ;~ $line ='[19/07/2011 22:01:15] Result: 2bfbab92 rejected [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' ;~ $line ='[19/07/2011 22:01:15] Result: 2bfbab92 rejected'&@CR&'[435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' if StringRegExp($line, '(?i)Result:(.*)accepted( *) ') = 1 or StringRegExp($line, '(?i)Result:(.*)accepted( *)'&@cr) = 1 then consolewrite ('+Result Acepted'&@lf) EndIf if StringRegExp($line, '(?i)Result:(.*)rejected( *) ') = 1 or StringRegExp($line, '(?i)Result:(.*)rejected( *)'&@cr) = 1 Then consolewrite ('!Result Rejected'&@lf) EndIf You can simplify that using the OR operator and '\r' for CR. ;$line ='[19/07/2011 22:01:15] Result: 2bfbab92 accepted [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' ;$line ='[19/07/2011 22:01:15] Result: 2bfbab92 accepted'&@CR&'[435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' $line ='[19/07/2011 22:01:15] Result: 2bfbab92 rejected [435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' ;~ $line ='[19/07/2011 22:01:15] Result: 2bfbab92 rejected'&@CR&'[435.10 Mhash/sec] [0 Accepted] [1 Rejected] [RPC (+LP)]' if StringRegExp($line, '(?i)Result:(.*)accepted( *)( |\r)') = 1 then ;any number, even zero, spaces followed by a space or a CR consolewrite ('+Result Acepted'&@lf) EndIf if StringRegExp($line, '(?i)Result:(.*)rejected( *)( |\r)') = 1 then consolewrite ('!Result Rejected'&@lf) EndIf Or you could say accepted( *\r*) ; 'accepted' followed by 0 or more spaces followed by 0 or more CR. if StringRegExp($line, '(?i)Result:(.*)accepted( *\r*)') = 1 then consolewrite ('+Result Acepted'&@lf) EndIf if StringRegExp($line, '(?i)Result:(.*)rejected( *\r*)') = 1 then consolewrite ('!Result Rejected'&@lf) EndIf Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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