praveenchappa has asked for the wisdom of the Perl Monks concerning the following question:
hi i had string which is the contents of a file and i need a regular expression to match and replace the following pattern.
string:OT; some line /*asas*/ ##here comments should be removed /*asdas*/ #OT;.....RT;should be replaced with OT;.....DT;OT.......RT; some line RT; some lines somlelines OT; some line /*asas*/ /*asdas*/ some line RT; 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; if($string=$string=~ s/OT;(.*?)(/*(.*?)*/)*(.*?)RT;/OT;$1$4DT;\nOT;$1$ +4RT;/gsr) { print "modified string".$string; }
please help me out
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need regular expression (OP needs to read the docs)
by ww (Archbishop) on Apr 14, 2015 at 15:35 UTC | |
|
Re: Need regular expression
by hdb (Monsignor) on Apr 14, 2015 at 14:29 UTC | |
|
Re: Need regular expression
by ww (Archbishop) on Apr 14, 2015 at 16:51 UTC |