in reply to how should i test whether a string contains between 6 and 20 letters and numbers
use strict; use warnings; while (<DATA>) { chomp; if (/^[a-zA-Z0-9]{6,20}$/) { print "Success: >$_<\n"; } else { print "Invalid string: >$_<\n"; } } __DATA__ Success Invalid string!
Prints:
Success: >Success< Invalid string: >Invalid string!<
Update: provide complete sample
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how should i test whether a string contains between 6 and 20 letters and numbers
by brian_d_foy (Abbot) on Jan 30, 2006 at 00:17 UTC | |
by GrandFather (Saint) on Jan 30, 2006 at 00:51 UTC | |
by brian_d_foy (Abbot) on Jan 30, 2006 at 01:20 UTC | |
by GrandFather (Saint) on Jan 30, 2006 at 01:55 UTC | |
by brian_d_foy (Abbot) on Jan 30, 2006 at 03:24 UTC | |
|