Newbie dot Org HomePage
Visit one of our web buddies
Regular Expressions
Sample / Examples
Return to main thread

#!/usr/bin/perl
use strict;

my (@arrayofstrings) = ('Newbie', 'NNewbie', 'NNNNNewbie', 'ewbie');
foreach my $string (@arrayofstrings) {
	print "$string -- ";
	if ($string =~ /N*ewbie/) {
		print " match found.\n";
	} else {
		print " no match.\n";
	}
}
exit;

Results:

Newbie --  match found.
NNewbie --  match found.
NNNNNewbie --  match found.
ewbie --  match found.



Return to main thread
A little extra

#!/usr/bin/perl
use strict;

my (@arrayofstrings) = ('Newbie', 'NNewbie', 'NNNeubie', 'eWbie');
foreach my $string (@arrayofstrings) {
	print "$string -- ";
	if ($string =~ /N*e.bie/) {
		print " match found.\n";
	} else {
		print " no match.\n";
	}
}
exit;

Results:

Newbie --  match found.
NNewbie --  match found.
NNNeubie --  match found.
eWbie --  match found.


Return to main thread