in reply to string matching
Same input, same output (but with those extra *)#!/usr/bin/perl -w use strict; while (<DATA>) { $_ =~ /(The seller has the following \*fruit\* types: )\(?([a-z ,* +]+)\)?\./; my ($const, $rep) = ($1, $2); $rep =~ s/\s?\*\s?/#/g; $rep =~ s/,? and/and/; print "$const*($rep)*.\n"; }
|
|---|