gcue Posted March 10, 2010 Share Posted March 10, 2010 I am trying to grab "CVS.IST.LO.NA.CUPD" from the text below Current context: CVS.IST.LO.NA.CUPD User: ERTTT Name: ERTTT Name: UT_442 creatorsName: CN=CONRLS Given Name: Eddie Group Membership: ACCESS_BROWFS15_TEAMS_DBA.CDS Group Membership: PC_SUPPORT.CDS.. here's what i have so far but not quite there yet.... what am i missing? $current_context = StringRegExp($novell_output, "($i)($s)(?x)current context[:ascii:\S]", 1, $ofs) _ArrayDisplay($current_context) Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 10, 2010 Share Posted March 10, 2010 (edited) Not even close. Try: "(?:Current context:\s*)(\S+)" Edit: Didn't have to escape the literal colon "\:". Edited March 10, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Fulano Posted March 10, 2010 Share Posted March 10, 2010 (edited) $current_context = StringRegExp($novell_output, "($i)($s)(?x)current context[:ascii:\S]", 1, $ofs) _ArrayDisplay($current_context) It looks like you can simplify things a bit: $current_context = StringRegExp($novell_output, "(?i)current context: [:alnum:.]+", 1) _ArrayDisplay($current_context)Breakdown: Changed the ($i) to (?i) because I believe it to be a typo. Removed the (?s)(?x) because you don't need to match newlines (in fact a newline terminates the string you want), and there is not comments to worry about, and whitespace is important to matching "current context" correctly. Based on you example, I changed :ascii: to :alnum:, to avoid weird punctuation sneaking in. Also I changed \S to . as that was the separator in your record. I think that was the functionality you were looking for because \S duplicates the :ascii: group. \s is whitespace, which is what I think you were going for. $ofs is optional, and doesn't appear to play into this particular case. Hope this helps Edited March 10, 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...
jchd Posted March 10, 2010 Share Posted March 10, 2010 @fulano, I believe the offset to be a leftover from a regexp answer I made to a previous post, where I needed the feature. @gcue, regexp are very logical (even if I'm not the only one to admit they can be tricky at times) and the nice thing is: they never bite you, I mean physically. So don't get afraid to spend some time playing with them, experimenting from simple ones to more complex, throwing new quantifiers and constructs as you progress. RegExCoach is perfect for that. The PCRE page link in the help page of StringRegExp is a definitive precise guide explaining everything in detail. Just forget about pure Perlisms at the end. 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...
Mison Posted March 11, 2010 Share Posted March 11, 2010 "(?<=Current context: )[^\v]+" Hi ;) Link to comment Share on other sites More sharing options...
gcue Posted March 11, 2010 Author Share Posted March 11, 2010 thanks mison and psalty that worked! fulano - didnt work for me 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