-----Original Message----- From: Jensen Kenneth B SrA AFPC/DPDMPQ [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 10:59 AM To: '[EMAIL PROTECTED]' Subject: Reqxp help
Trying to make a one liner regxp to covert a file. File has lines like these (lines are preceded with a space) Dec 20 13:28 guard/AFRC_AFRC00_01 Nov 22 2001 guard/ANCHORAGE_668300_14 Dec 20 08:46 guard/ALPENA_MI_503000_79 Dec 30 06:51 guard/ANDREWS_MD_525700_93 Output needs to look like this with pipelines inserted. Dec| 20| 13:28 |guard/|AFRC_AFRC|00_|01 Nov| 22| 2001 |guard/|ANCHORAGE_6683|00_|14 Dec| 20| 08:46 |guard/|ALPENA_MI_5030|00_|79 Dec| 30| 06:51 |guard/|ANDREWS_MD_5257|00_|93 The regex's I've tried have been pretty far off. Any help in this greatly appreciated. Ken -----Response Follows----- I'd like to see what you tried. I just walked through what I saw you wanted, literally, almost a character at a time and came up with the following pretty quickly: @arr = (' Dec 20 13:28 guard/AFRC_AFRC00_01 ', ' Nov 22 2001 guard/ANCHORAGE_668300_14 ', ' Dec 20 08:46 guard/ALPENA_MI_503000_79 ', ' Dec 30 06:51 guard/ANDREWS_MD_525700_93 '); foreach $str (@arr) { if ($str =~ /( \w{3})( \d{2})( \d{2}:?\d{2} )(\w+\/)(.*)(\d{2}_)(\d{2} )/) { print $1.'|'.$2.'|'.$3.'|'.$4.'|'.$5.'|'.$6.'|'.$7."\n"; } else { print "bad regexp\n"; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]