gcue Posted March 11, 2010 Share Posted March 11, 2010 (edited) can an or be said in a regexp statement?for example in this text i want to capture text AFTER "Login Script:" (note: each new line after ONLY if the first word is "map" OR "@NET" Login Script: map k:=lo-ncs_users2_server\users2:@NET USE x: \\loap01\tes Login Time: 05:09:48 am 03/11/10 modifiersName: CN=CGNDSDR1 Edited March 11, 2010 by gcue Link to comment Share on other sites More sharing options...
Pain Posted March 11, 2010 Share Posted March 11, 2010 (edited) | Or. The expression on one side or the other can be matched. Edit: The formating got screwed, a vertical line is the OR operator. Edited March 11, 2010 by Pain Link to comment Share on other sites More sharing options...
Fulano Posted March 11, 2010 Share Posted March 11, 2010 It's worth noting that the RegExp syntax is a bit different that you will find for grep or perl perl/grep style:(first|second) AutoIt style[first|second] That'll cause you problems if you are converting a regexp you found online somewhere. Good luck #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
GEOSoft Posted March 11, 2010 Share Posted March 11, 2010 SsStr = FileRead("some file containing the text you supplied.txt") $aArray = StringRegExp(StringRegExpReplace($sStr, "(?i)(?s).*login\sscript.+?\v+(.+$)", "$1"), "(?i)(?m:^)(map.+|@net.+)(?:\v|\z)", 3) If NOT @Error Then For $i = 0 To Ubound($aArray) ;; Do What you want here Next EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted March 11, 2010 Share Posted March 11, 2010 It's worth noting that the RegExp syntax is a bit different that you will find for grep or perl perl/grep style:(first|second) AutoIt style[first|second] That'll cause you problems if you are converting a regexp you found online somewhere. Good luck You might want to reconsider that. Using your example AutoIt will match any of the characters between "[" and "]" George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Fulano Posted March 11, 2010 Share Posted March 11, 2010 (edited) You might want to reconsider that. Using your example AutoIt will match any of the characters between "[" and "]" Dang, you're right! Sorry about that folks, wrong language. Edit: Realized what language was tripping me up. Got AutoIt confused with Javascript there for a moment. Sorry about the mixup. Edited March 11, 2010 by Fulano #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
gcue Posted March 11, 2010 Author Share Posted March 11, 2010 works great geo! thanks!!! Link to comment Share on other sites More sharing options...
GEOSoft Posted March 11, 2010 Share Posted March 11, 2010 Dang, you're right! Sorry about that folks, wrong language.Edit: Realized what language was tripping me up. Got AutoIt confused with Javascript there for a moment. Sorry about the mixup. And therein lies the major drawback to SRE's, there are just too many flavors of it. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 11, 2010 Author Share Posted March 11, 2010 (edited) Geo, sometimes theres a space between @ and NET i tried throwing in the (?x) but it doesnt seem to work.. StringRegExp(StringRegExpReplace($novell_output, "(?i)(?s).*login\sscript.+?\v+(.+$)", "$1"), "(?i)(?m:^)[b](?x)[/b](map.+|@net.+)(?:\v|\z)", 3) Edited March 11, 2010 by gcue Link to comment Share on other sites More sharing options...
Fulano Posted March 11, 2010 Share Posted March 11, 2010 (?x) ignores whitespace in the regex so you can make it more readable. Try putting \s* between @ and NET #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
GEOSoft Posted March 11, 2010 Share Posted March 11, 2010 Geo, sometimes theres a space between @ and NET i tried throwing in the (?x) but it doesnt seem to work.. StringRegExp(StringRegExpReplace($novell_output, "(?i)(?s).*login\sscript.+?\v+(.+$)", "$1"), "(?i)(?m:^)[b](?x)[/b](map.+|@net.+)(?:\v|\z)", 3) $aArray = StringRegExp(StringRegExpReplace($sStr, "(?i)(?s).*login\sscript.+?\v+(.+$)", "$1"), "(?i)(?m:^)(map.+|@\s*net.+)(?:\v|\z)", 3) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 11, 2010 Author Share Posted March 11, 2010 (edited) got it-thanks!!!!! ok im starting to understand this.. just the placement of things is sometimes weird thanks for your help fellas. Edited March 11, 2010 by gcue Link to comment Share on other sites More sharing options...
GEOSoft Posted March 11, 2010 Share Posted March 11, 2010 got it-thanks!!!!!ok im starting to understand this.. just the placement of things is sometimes weirdthanks for your help fellas.Glad to help.PM me if you want a tool for testing SRE's George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 11, 2010 Author Share Posted March 11, 2010 im looking at different ones.. which one u have in mind? Link to comment Share on other sites More sharing options...
GEOSoft Posted March 11, 2010 Share Posted March 11, 2010 im looking at different ones.. which one u have in mind?The one I use mainly is a version by Szhlopp and wOuter and highly modified by me (constantly modified I might add). I also use Expresso on occasion but none of the ones you will find on line are AutoIt specific and often the RegExp that you test will be fine in the tester and not when used in your code. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 11, 2010 Author Share Posted March 11, 2010 are there any that are autoit specific? Link to comment Share on other sites More sharing options...
GEOSoft Posted March 11, 2010 Share Posted March 11, 2010 are there any that are autoit specific?The one I modified. That's the one I'll send if you want it. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 11, 2010 Author Share Posted March 11, 2010 defnitely - thanks! Link to comment Share on other sites More sharing options...
gcue Posted March 11, 2010 Author Share Posted March 11, 2010 (edited) i tried to use the same syntax for another example but i cant figure out why its not working Last Intruder Address: TCP/IP Network Address IP Address: 30.20.212.274 Maximum Connections: 6 Login Script: map k:=lo-ncs_usrs2_server\usrs2: @NET USE x: \\loap01\tms Login Time: 05:09:48 am 03/11/10 modifiersName: CN=CGNDSDR1 Network Address: TCP/IP Network Address IP Address: 30.20.12.14 StringRegExp(StringRegExpReplace($novell_output, "(?i)(?s).*last\sintruder\saddress.+?\v+(.+$)", "$1"), "(?i)(?m:^)(ip\saddress.+)(?:\v|\z)", 3) _ArrayDisplay($novell_last_intruder_address) i didnt put the * after \s because it will always have a space between those instances Edited March 11, 2010 by gcue Link to comment Share on other sites More sharing options...
GEOSoft Posted March 11, 2010 Share Posted March 11, 2010 i tried to use the same syntax for another example but i cant figure out why its not working StringRegExp(StringRegExpReplace($novell_output, "(?i)(?s).*last\sintruder\saddress.+?\v+(.+$)", "$1"), "(?i)(?m:^)(ip\saddress.+)(?:\v|\z)", 3) _ArrayDisplay($novell_last_intruder_address) i didnt put the * after \s because it will always have a space between those instances $aArray = StringRegExp($RegExpReplace($novel_output, "(?i)(?s)Last\sIntruder.+?\v+(.+$)", "$1"), "(?i)(?m:^)(ip\saddress.+)(?:\v|\z)", 3) _ArrayDisplay($aArray) Works for me. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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