in reply to Regex checking text is made up of the keys of a hash.

You might not want the case insensitivity or to allow spaces between the language token and the comma, but I added them for completeness.

#! perl -slw use strict; my %validLanguages = ( "de" => "german", "en" => "english", "es" => "spanish", "fr" => "french", "it" => "italian", "ja" => "japanise", "ko" => "korean", "ru" => "russian", "sv" => "WHATS THIS", "zh" => "WHATS THIS", "zh_TW" => "WHATS THIS" ); my $re_langs = join'|', keys %validLanguages; $re_langs = qr[\s*(?:$re_langs)\s*(?:,|$)]io; sub isOnlyLangs{ my ($string) = @_; $string =~ s[$re_langs][]g; $string =~ m[^\s*$]; } sub isOnlyLangs_{ (my $s = $_[0]) =~ s[$re_langs][]g; !$s; } print isOnlyLangs($_) ? 'Passed : ' : 'Failed : ', "'$_'" for 'de, en, fr, ja', ' de , en , fr , ja , ', 'monkish fr, en', 'monkish, fr, en', 'FR', 'Fr', 'fr en', 'fr , en,', 'zh_tw';

Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.