Sign in to follow this  
Followers 0
gcue

isolating sections of a long variable

5 posts in this topic

I am trying to isolate sections of the variable ($output)

"message: snapshot completed successfully

started at: Tuesday, December 09, 2008 9:30:02am

finished at: Tuesday, December 09, 2008 9:41:45am

number of files: 59929

Amount of data: 8.77 GB

Local Event Code: 0x4002001f

System Event COde: 0x29392"

id like to just capture each field seperately (message, started at, etc).

i tried using stringsplit but had alot of difficulty

msgbox(0, "", $output)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I am trying to isolate sections of the variable ($output)

"message: snapshot completed successfully

started at: Tuesday, December 09, 2008 9:30:02am

finished at: Tuesday, December 09, 2008 9:41:45am

number of files: 59929

Amount of data: 8.77 GB

Local Event Code: 0x4002001f

System Event COde: 0x29392"

id like to just capture each field seperately (message, started at, etc).

i tried using stringsplit but had alot of difficulty

msgbox(0, "", $output)
StringRegExp()... it's like... magic!
#include <Array.au3>

$sString = "message: snapshot completed successfully" & @CRLF & _
"started at: Tuesday, December 09, 2008 9:30:02am" & @CRLF & _
"finished at: Tuesday, December 09, 2008 9:41:45am" & @CRLF & _
"number of files: 59929" & @CRLF & _
"Amount of data: 8.77 GB" & @CRLF & _
@CRLF & _
"Local Event Code: 0x4002001f" & @CRLF & _
"System Event COde: 0x29392"

$avParts = StringRegExp($sString, "(?:\:)(.*)(?:\r)", 3)
_ArrayDisplay($avParts, "$avParts")

:)

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

perfect!

thanks.. thats tough syntax - still trying to undeerstand it

*sigh*

Share this post


Link to post
Share on other sites

perfect!

thanks.. thats tough syntax - still trying to undeerstand it

*sigh*

Just turn around 20 times, stop and start coding right away... It will all be a lot more clear to you :)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

perfect!

thanks.. thats tough syntax - still trying to undeerstand it

*sigh*

It's not that hard (though Jos' suggestion might help).

It captures anything between a ":" and a @CR. I don't want to include the ":" and @CR in the captured string, so it uses "non-capturing groups" for those parts which are signaled by "?:". Escape sequences are used to specify the literal ":" with "\:" and literal @CR with "\r". The middle part ".*" is just anything that might be between the other two, and since it is the only group without the non-capturing specified, that is the only group returned in the array.

:)


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

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  
Followers 0