in reply to string matching
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#)*.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: string matching
by newbio (Beadle) on Aug 01, 2009 at 18:55 UTC | |
by BrowserUk (Patriarch) on Aug 01, 2009 at 19:20 UTC |