in reply to regular expression math equations
If you have to match alphanumerics (eg. a7), then use something like ([a-z]\w*0) instead.
Of course, any problem requiring unique results just shouts out for a hash.
You could try something like this:
use strict; use warnings; + print "Enter expression: "; chomp(my $expr = <STDIN>); + my @vars = ($expr =~ /([a-z]+)/gi); my %unique = map { $_ => 1 } @vars; + printf "Unique variables: %s\n", join(',',keys %unique);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regular expression math equations
by imp (Priest) on Nov 20, 2006 at 14:59 UTC |