in reply to Stumped by regex
HI,
If the length of the string is greater than 20 then that string is ignored and skipped to next string.
while (<DATA>) { unless (length($_) > 20 ) { if ($_=~m#^[a-zA-Z]+(\s?[a-zA-Z]+)?$#) { print $_ . "\n"; } } } __DATA__ Johnson Larry Wall GeorgeWashingtonBushBush
Results:
Johnson
Larry Wall
Don't put off till tomorrow, what you can do today.
|
|---|