Actually, first attempts weren't because of bad regexp but another stupid bug I had earlier when I was opening the file. I have it working now using:
#!/usr/contrib/bin/perl open (TEST, "@ARGV[0]"); open (OUT, ">@ARGV[0].out"); while (<TEST>){ s/\s(\S+)\s+(\d+)\s+(\S+)\s(\S+\/)(\S+\_)(\S+)(00\_)(\d+)/$1\| $2\| $3 \|$4\|$5\|$6\|$7\|$8/; print OUT "$_\n"; } close OUT; close TEST; -----Original Message----- From: Mark Anderson [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 1:20 PM To: Jensen Kenneth B SrA AFPC/DPDMPQ; [EMAIL PROTECTED] Subject: RE: Reqxp help -----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"; } }