Welcome to the Monastery!

Please see Writeup Formatting Tips to format your post better.

Try this:

use strict; use warnings; local $/="\n\n"; while (<DATA>){ if ( my ($prefix,$suffix)=m/\[WinEventLog:.+index = (\w+)_(pr|np)\s +*$/s){ # print "$prefix\_$suffix found .. replacing...\n"; s/index = $prefix\_$suffix\s*$/index = window_$suffix\n\n/; } print ; } __DATA__ [WinEventLog://Application] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = CNDO_pr [WinEventLog://Security] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = CGWS_pr [WinEventLog://System] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = DMRW_pr [WinEventLog://ForwardedEvents] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = NENP_pr [WinEventLog://Setup] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = EOFK_pr [WinEventLog://Application] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = FDWD_np [WinEventLog://Security] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = ASKD_np [WinEventLog://System] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = JMSF_np [WinEventLog://ForwardedEvents] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = JCCD_np [WinEventLog://Setup] checkpointInterval = 5 current_only = 0 disabled =0 start_from = oldest index = HSMS_np

                "From there to here, from here to there, funny things are everywhere." -- Dr. Seuss


In reply to Re: Regex for replacing capture group content using perl by NetWallah
in thread Regex for replacing capture group content using perl by Zagidi

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.