2nd comment since OP has not responded to the previous nodes

#! /usr/bin/perl -w use 5.018; my $string = "OT; some line /*asas*/ # here C-style comments should be removed /*asdas*/ #OT;.....RT;should be replaced with OT;.....DT;OT.... +...RT; *note1 some line RT; some lines somlelines OT; another line /*asas*/ /*asdas*/ yet another line RT;"; =head first, my note: # /me does not understand WTF the OP's comment above means and now, OP's spec: what i need is like OT; some line1 some line2 DT; OT; some line1 some line2 RT; some lines3 somlelines4 OT; some line5 some line6 DT: OT; some line5 some line6 RT; =cut my $regex1 = qr([/][*]); my $regex2 = qr([*][/]); $string =~ s/$regex1.+?$regex2//gs; say $string; =head output C:\> junk_check.pl OT; some line # here C-style comments should be removed #OT;.....RT;should be replaced with OT;.....DT;OT.......RT; *n +ote1 some line RT; some lines somlelines OT; another line yet another line RT; C:\> =cut

The above does part of what you ask, without deleting the Perl-style comments, but /me does NOT understand your spec re inserting DT; (or DT: as in an instance in your example). Perhaps, if not in your own interest, in the interest of future readers, you will clarify the intent (and the probable typo) by an explicit explanation of when DT; should be inserted.


If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.

In reply to Re: Need regular expression by ww
in thread Need regular expression by praveenchappa

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.