in reply to regular expressions with commas?

Well, here is what I would start with:

use strict; while(<DATA>) { #using re match. # match beginning, anything except comma, # followed by a comma and 'Y' if(m/^([^,]+),Y/) { print "RE Name:" . $1 . "\n"; } } __DATA__ davis,N brown,Y smith,Y,N,B jones,N,Y,B,A clarke,Y,N,Y

Or Perhaps:

use strict; while(<DATA>) { my @data = split(','); if($data[1] eq 'Y') { print "RE Name:" . $data[0] . "\n"; } } __DATA__ davis,N brown,Y smith,Y,N,B jones,N,Y,B,A clarke,Y,N,Y

Hazah! I'm Employed!

Replies are listed 'Best First'.
Re^2: regular expressions with commas?
by chas (Priest) on Dec 10, 2005 at 14:49 UTC
    Those both match given the string "Blah,Y,X", which has a substring ending with ",Y", but doesn't itself end with that sequence. (It isn't completely clear to me what the OP wanted, though...)

      I interpreted it as meaning a ",Y" after the name string. Many others interpreted it as meaning a ",Y" at the end of the line. The OP wasn't clear so I figure I would share my interpretation.

      Hazah! I'm Employed!

Re^2: regular expressions with commas?
by webshark (Acolyte) on Dec 10, 2005 at 11:33 UTC
    cheers guys... works a treat..