On Wed, 2005-06-08 at 10:41 -0400, |TF20|Shockwave wrote: > ----- Original Message ----- > From: "Dotan Cohen" <dotancohen@xxxxxxxxx> > To: "For users of Fedora Core releases" <fedora-list@xxxxxxxxxx> > Sent: Wednesday, June 08, 2005 9:11 AM > Subject: Very simple regex > > > > Now, I know that this is easy, but I am embarassed to say that I can't > > find a regex tutorial that will show me how to match any occurances of > > x and replace them with one x: > > > > xxxxx >x > > xx > x > > x > x > > > > $string="I have xxxxxxxx apples!"; > > $string=preg_replace("-regex here-","x", $string); > > print "$string"; > > > > I have x apples! > > > > In Perl: > $string =~ s/x+/x/g; > > If you are looking to do this against a text file name sample.txt: > > sed -e 's/x\+/x/g' sample.txt Or even: tr -s x < sample.txt Paul. -- Paul Howarth <paul@xxxxxxxxxxxx>