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.
In reply to Re: Need regular expression
by ww
in thread Need regular expression
by praveenchappa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |