0
我有一個代碼,並得到一個系統日誌消息是這樣的:如何將一個系統日誌消息寫入一個數組?
May 11 10:40:48 scrooge disk-health-nurse[26783]: [ID 702911 user.error] m:SY-mon-full-500 c:H : partition health measures for /var did not suffice - still using 96% of partition space
有沒有在我能夠把這個代碼陣列在這樣的代碼:
array [0] = May 11 10:40:48
array [1] = scrooge
array [2] = scrooge disk-health-nurse[26783]:
array [3] = [ID 702911 user.error]
array [4] = m:SY-mon-full-500
array [5] = c:H : partition health measures for /var did not suffice - still using 96% of partition space
聽起來很邏輯。但是如果String中有一部分可能是DateTime-Object,那麼是不是有一種要求完整字符串的代碼? – semaxx 2015-02-24 12:55:00
是的。如果您知道DateTime實例的格式,則必須使用Regex。例如,請參閱http://stackoverflow.com/questions/14917203/finding-if-a-string-contains-a-date-and-time。 – EngineerSpock 2015-02-24 12:56:51