topical media & game development

talk show tell print

basic-regex-26-DoubledWord.pl / pl



  #!/usr/bin/perl -w
  use strict;
  my myPattern = "(\\w+)(\\s+\\1\\b)";
  my myTestString = "Paris in the the Spring Spring.";
  print "The original string was 'myTestString'.\n";
  myTestString =~ s/myPattern/1/g;
  print "The captured group was: '$1'.\n";
  print "Any doubled word has now been removed.\n";
  print "The string is now 'myTestString'.\n";


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.