in reply to regex: only want [a-zA-Z] and comma chars in a string
I really learned some things here. My solution forgot to include the ^ and $ anchors at first and didn't work. After reading Dragonchilds reply, I went back to examine the behavior of split (was instructive). By suppling the -1 (infinitely large) number of field to split into, he preseved the trailing item. Really liked Nevyn's solution - very staightforward and clear, easy to understand.
Once I put in the anchors, my regex worked correctly - surprise!
my $pat = qr{^([A-Za-z]|[A-Za-z],(?=[A-Za-z]))+$};
Nice to meet all,
Chris
|
|---|