Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi Fellow Monks,

Good Day.
A few minutes back while coding I faced the below problem.

I was trying to match all the string till it matches two consecutive new line character. Usually I use negative look ahead format for matching such kind of string. But today I was not able to match the string and I got the below error message since I used 'warnings'.

May I know the reason why I am getting the error, can't I use newline characters for these kind of matching?

The below code and data is sample for testing, not real code and data.

use strict; use warnings; my $s = do {local $/, <DATA>}; $s =~ s/\w+\s+\w+\s*\d+\s*\,(?:(?!(?:\n\n).)*)\n\n/'test'/egsi; #getti +ng error #$s =~ s/\w+\s+\w+\s*\d+\s*\,.*?\n\n/'test'/egsi; #working fine print $s; output: ------- (?!(?:\n\n).)* matches null string many times in regex; marked by <-- +HERE in m/ \w+\s+\w+\s*\d+\s*,(?:(?!(?:\n\n).)* <-- HERE )\n\n/ at pract.pl line +6. LMTRILOG db 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 +, 0 , 0 , 0; db 25 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 + , 0 , 0 , 0; __DATA__ LMTRILOG db 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 +, 0 , 0 , 0; db 25 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 + , 0 , 0 , 0;
updated: added __DATA__

Thanks in advance

Prasad


In reply to Negative Look Ahead issue by prasadbabu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-20 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found