Which prints out:my ($date_stamp,$event,$alert_id,$status); my $str = '2001/03/12 time>Event [21]Alert Completed (34562), Status: +[22] Alert Completed,MN_netware-support'; ($date_stamp,$event,$alert_id,$status) = $str =~ /^([\d\/]+).*?(Event.*?ed) \((\d+)\), (.*)$/; print "[$date_stamp]\n"; print "[$event]\n"; print "[$alert_id]\n"; print "[$status]\n";
This may well break depending on what variation there is in the rest of the data, but it may serve to get you started.[2001/03/12] [Event [21]Alert Completed] [34562] [Status: [22] Alert Completed,MN_netware-support]
^ start at the beginning of the line ([\d\/]+) match and save a bunch of digits and /'s .*? lazily match and ignore stuff until... (Event.*?ed) match and save of 'Event...ed' match but ignore the following space \( match a literal paren (\d+) match and save a bunch of digits \), match and ignore literal paren, comma, and space (.*) match and save anything until... $ the end of the string
In reply to Re: split delimiters #2
by dvergin
in thread split delimiters #2
by bailybj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |