Skip to main content
Add Perl syntax highlighting
Source Link
Benjamin Loison
  • 5.8k
  • 4
  • 20
  • 37

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"; } 

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"; } 

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"; } 
Fixed the weird syntax highlighting (as a result, the diff looks more extensive than it really is - use view "Side-by-side Markdown" to compare), etc.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

The following regex matches alphanumeric characters and underscore:

^[a-zA-Z0-9_]+$ 
^[a-zA-Z0-9_]+$ 

For example, in Perl:

#!/usr/bin/perl -w my $arg1 = $ARGV[0]; # checkCheck 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"; } 

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"; } 

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"; } 
Added full regex
Source Link
Jay
  • 42.9k
  • 14
  • 69
  • 83

The following regex matches alphanumeric characters and underscore:

[a^[a-zA-Z0-9_]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"; } 

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"; } 

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"; } 
Source Link
Jay
  • 42.9k
  • 14
  • 69
  • 83
Loading