... why lines #1 & #8 didn't match in Perl...
Because I'm an idiot, in a hurry
I forgot to fix the named classes in your pattern, so they weren't working properly, and I somehow lost the trailing space on #8.
Once I actually pay attention to what I'm doing, it works much better (only #11 does not match).
Just for kicks, here is what your pattern would look like in Perl, along with the output when run against your sample:
Code: Select all
#!/usr/bin/perl -n
chomp;
my $match =
/
[[:space:],.]$
|
^[[:space:],.[:lower:]]
|
[[:space:]]{2}
|
([[:alnum:]][.,][[:alnum:]])
/ox;
printf("%2d: %-8s %s\n", $., "'$_'", $match ? "matched <$`'$&'$'>" : "no match");
Code: Select all
$ perl abx e
1: ' E' matched <' 'E>
2: ',E' matched <','E>
3: '.E' matched <'.'E>
4: 'ee' matched <'e'e>
5: 'E e' matched <E' 'e>
6: 'E,e' matched <'E,e'>
7: 'E.e' matched <'E.e'>
8: 'E ' matched <E' '>
9: 'E,' matched <E','>
10: 'E.' matched <E'.'>
11: 'End' no match
Perhaps this will help make it clear why the named classes are meant to appear inside "[classes]" and not to stand on their own.