Jump to content
Sign in to follow this  


Recommended Posts


I am trying to grab "CVS.IST.LO.NA.CUPD" from the text below

Current context: CVS.IST.LO.NA.CUPD



Name: UT_442

creatorsName: CN=CONRLS

Given Name: Eddie


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)

Share this post

Link to post
Share on other sites

Not even close. Try: "(?:Current context:\s*)(\S+)"


Edit: Didn't have to escape the literal colon "\:".

Edited 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

Share this post

Link to post
Share on other sites

$current_context = StringRegExp($novell_output, "($i)($s)(?x)current context[:ascii:\S]", 1, $ofs)

It looks like you can simplify things a bit:

$current_context = StringRegExp($novell_output, "(?i)current context: [:alnum:.]+", 1)

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 :mellow:

Edited 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!

Share this post

Link to post
Share on other sites


I believe the offset to be a leftover from a regexp answer I made to a previous post, where I needed the feature.


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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post

Link to post
Share on other sites

thanks mison and psalty that worked!

fulano - didnt work for me

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.