R
rahul
Greetings,
I am trying to match english words in a string with white space(s) as
delimiter. Additionally, I am trying to match a period at the end of a
word/sentence. I've made a few attempts after reading perlre/perretut
but have not succeeded. Any help would be appreciated. Here's my script
-
#!C:\perl\bin\perl.exe
use strict;
use warnings;
my $ps = '1no . woRd5 he8re. a_nd n;one ,here eith!er hj.. .. This iS
a vAlid sTatement.';
foreach(split /\s+/,$ps){
#if (/^\b[^\d]*([a-zA-Z])[^\d]*(\.?)\b$/){
#if (/^\b([a-zA-Z]+)[\.]?\b$/){
#if (/^\b[a-zA-Z]+[\.]{0,1}\b$/){
if (/^\b[a-zA-Z]+(\.?)\b$/){
print "$_: yes\n";
}
else {
print "$_: no\n";
}
}
I am trying to match english words in a string with white space(s) as
delimiter. Additionally, I am trying to match a period at the end of a
word/sentence. I've made a few attempts after reading perlre/perretut
but have not succeeded. Any help would be appreciated. Here's my script
-
#!C:\perl\bin\perl.exe
use strict;
use warnings;
my $ps = '1no . woRd5 he8re. a_nd n;one ,here eith!er hj.. .. This iS
a vAlid sTatement.';
foreach(split /\s+/,$ps){
#if (/^\b[^\d]*([a-zA-Z])[^\d]*(\.?)\b$/){
#if (/^\b([a-zA-Z]+)[\.]?\b$/){
#if (/^\b[a-zA-Z]+[\.]{0,1}\b$/){
if (/^\b[a-zA-Z]+(\.?)\b$/){
print "$_: yes\n";
}
else {
print "$_: no\n";
}
}