in reply to string containing characters
What this little program does not do is that it does not count how many letters are matched. So, if you want to know if a string contains at least 5 letter A's and 3 B's and 2 C's, then this program is not going to work...
#!/usr/bin/perl -w use strict; use warnings; my $SAMPLE = "Hello World\r\n"; my $MATCHALL = "oreH"; $MATCHALL =~ s/[\Q$SAMPLE\E]+//g; if (length($MATCHALL) == 0) { print "\nCONTAINS ALL THE CHARACTERS\n"; } else { print "\nDOES NOT CONTAIN ALL THE CHARACTERS\n"; } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: string containing characters
by ikegami (Patriarch) on Jan 21, 2025 at 22:39 UTC | |
by harangzsolt33 (Deacon) on Jan 22, 2025 at 01:17 UTC | |
by ikegami (Patriarch) on Jan 22, 2025 at 14:52 UTC | |
by harangzsolt33 (Deacon) on Jan 29, 2025 at 02:48 UTC |