Multi-line processing help needed 
Author Message
 Multi-line processing help needed

Hi,

Could someone help me with multi-line processing?
When I attempt to match on a character after a single "\n", it matches.
However, if I try to match that character after 2 "\n"s it doesn't match
(I've tried "\s" also).
Could someone tell me how to do this correctly?

Please note that I'm using BPERL w/ DOS.

An example input file looks like this:
----------
word1
word2

word3
----------

And the program looks like this:

----------
$/="";
$*=1;

while (<>) {

s/\n/XXX/g;                    #catches "\n"s before "word2" and "word3"
        #outputs:
        #word1XXXword2XXXXXXword3XXXXXX

#s/\n(.)/\nXXX\1/g;             #catches start of "word2" but not "word3"
        #outputs:
        #word1
        #XXXword2
        #
        #word3

#s/\n\n(.)/\n\nXXX\1/g;         #does not catch "word3"
        #outputs:
        #word1
        #word2
        #
        #word3

s/\n.\n(.)/\n\nXXX\1/g;         #does not catch "word3"
        #outputs:
        #word1
        #word2
        #
        #word3

print;

Quote:
}

Thanks for any help!

---
Kevin J. Jarnot - Senior Software Developer    |        "Vita non jerk"
IDD Information Services  Waltham, MA          |

                                               |          of the beast



Fri, 14 Mar 1997 06:09:01 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. multi-line regexp help needed

2. Need help with multi-line regexp

3. Need help trying to do multi-line regexp

4. Processing multi-line entities with perl

5. Multi-line processing

6. Multi-line regex w/ multi-file loop

7. help with multi-line pattern requested

8. Multi-line comments in perl. (help)

9. HTML Multi-Line Subtitutions (Help!)

10. Help: Multi-line matching problem

11. help reading multi-line text file

12. Multi line match help

 

 
Powered by phpBB® Forum Software