Something like this?
#! perl -slw use strict; while( <DATA> ) { chomp; s[^(\QThe seller has the following *fruit*\E types:)(.+)$]{ my($const, $rep ) = ( $1, $2 ); $rep =~ tr[* ().][#]d; $rep =~ s[,\s*and][and]; "$const*($rep)*." }e; print; } __DATA__ The seller has the following *fruit* types: ( *apples* , *oranges* , * +pears* , *berries* , and *mangoes* ). The seller has the following *fruit* types: *apples* , *oranges* , *p +ears* , *berries* , and *mangoes* . The seller has the following *fruit* types: ( *apples* , *oranges* , * +pears* , *berries* and *mangoes* ). The seller has the following *fruit* types: *apples* , *oranges* , *p +ears* , *berries* and *mangoes* .
Output:
c:\test>785401.pl The seller has the following *fruit* types:*(#apples#,#oranges#,#pears +#,#berries#and#mangoes#)*. The seller has the following *fruit* types:*(#apples#,#oranges#,#pears +#,#berries#and#mangoes#)*. The seller has the following *fruit* types:*(#apples#,#oranges#,#pears +#,#berries#and#mangoes#)*. The seller has the following *fruit* types:*(#apples#,#oranges#,#pears +#,#berries#and#mangoes#)*.
In reply to Re: string matching
by BrowserUk
in thread string matching
by newbio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |