topical media & game development

talk show tell print

basic-regex-26-CapturedGroups.pl / pl



  #!/usr/bin/perl -w
  use strict;
  my myPattern = "([A-Z])(\\d)";
  my myTestString = "B99";
  myTestString =~ m/myPattern/;
  print "The pattern is 'myPattern'.\n";
  print "The test string is 'myTestString'.\n";
  print "The whole match is '&', contained in the $& variable.\n";
  print "The first captured group is '$1', contained in '$1'.\n";
  print "The second captured group is '$2', contained in '$2'\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.