in reply to Regex Help

Well, I found a way to remove the control characters after each line:
perl -p -e "s/\r+//" file.txt > newfile.txt
and I thought for sure, this would work, but I still can't get it to match :-(

I tried every regex possible, but no luck, here's how I'm calling it:
while (<FILE>){ /ATDT\d+\s+BUSY/ ? print : print "Did not match '$_'\n"; #print if /ATDT\d+\s+BUSY/; #print if /ATDT\d+.*BUSY/s; #print; }
L~R,

It looks like they took down the download files for Perl Power Tools.

eXile,

I tried your code, but I'm getting
The system cannot find the file specified.
I don't see where I'm suppose to specify the input file?

Abigail,

Thanks for the suggestion, but as you can see above I tried it, still not working.

Roy,

Everything gets printed back, including the lines I'm trying to match on
Did not match 'Output: Got ."ATDT1234567' ' Did not match 'BUSY

Replies are listed 'Best First'.
Re: Regex Help
by Abigail-II (Bishop) on Jun 07, 2004 at 20:47 UTC
    As I said, you are iterating over your input line by line. Your loop will never see a string where a newline separates "ATDT" and "BUSY". Don't loop line by line if you want to do multiline matching.

    Abigail

Re^2: Regex Help
by eXile (Priest) on Jun 08, 2004 at 00:28 UTC
    Hi, I'm sorry, I've added a Unix-style 'echo' in my code, just to prove the concept. Suppose you've captured the whole string in $string, you could do a rudimentary dump by:
    @chars=split //, $string; for(@chars) { print $_ . " " . ord($_) . "\n"; }
    This will print one character and its ascii decimal code per line (of course this will also output a newline as a newline, so the output isn't very pretty)