I am in need of help to better parse lines. Maybe using regular experssions, witch I am not able yet to do :( Well the line I need to parse is:
1221,INFORMATIONAL,MSExchangeIS Mailbox Store,Wed Jul 11 02:45:28 2007,No User,The database "SG1\Mailbox Store 1 (XOMMST01V01)" has 7457 megabytes of free space after online defragmentation has terminated. For more information, click http://www.microsoft.com/contentredirect.asp.
I want to get 2 informations outputed to strA, strB format . I want to get strA = "SG1...01v01) then strB = 7457
here is how I am doing it now, but the problem is not that not always the line is the same so it dosent work always!
Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Here is a start, assumes that SG1 is always the start of the section you want and there is only 1 ) in the string
str1 = "1221,INFORMATIONAL,MSExchangeIS Mailbox Store,Wed Jul 11 02:45:28 2007,No User,The database ""SG1\Mailbox Store 1 (XOMMST01V01)"" has 7457 megabytes of free space after online defragmentation has terminated. For more information, click http://www.microsoft.com/contentredirect.asp."
thanks I will try that, but yes the string usally starts with "SG.... X" but finishes in different ways not always a ) but it is always between " " and then the second part is alwys a number after the word "has" and before word "megabytes" ex: has 7457 megabytes
Wow it worked perfect! I love those Regular Expressions, wish I knew how to use it... mayb a link with some tips to it? Like this Pattern: RegEx.Pattern = "database\s""(.*)""\shas ([0-9]+)"
strToParse "The database "SG1\Mailbox Store 1 (XSDMST01V01)" has 7457 megabytes of free space after online defragmentation has terminated."
databse\s""(.*) What does it do??? \shas ([0-9]+)" after has get all number 0 to 9 ?
Posts: 2663
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
database = taken literally \s = a single space "" = look for " () around the .* = defines a group . = means any character * = means the character can show up 0 or more times "" = look for " again \s = a single space again has = taken literally again () = define another group [0-9] = any number between 0 and 9 + = occurs 1 or more times