The following regex matches alphanumeric characters and underscore:
^[a-zA-Z0-9_]+$ For example, in Perl:
#!/usr/bin/perl -w my $arg1 = $ARGV[0]; # Check that the string contains *only* one or more alphanumeric chars or underscores if ($arg1 !~ /^[a-zA-Z0-9_]+$/) { print "Failed.\n"; } else { print "Success.\n"; } #!/usr/bin/perl -w my $arg1 = $ARGV[0]; # Check that the string contains *only* one or more alphanumeric chars or underscores if ($arg1 !~ /^[a-zA-Z0-9_]+$/) { print "Failed.\n"; } else { print "Success.\n"; }