[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Regular Expression Definition



In the interest of There's More Than One Way to Do It, here's my solution:

Since I couldn't tell if having the # character and the same number of
spaces was important, here are two versions of the program, one which
preserves the # and spaces, and the other which gets just the string:

$_="\012 YY,XX   BIN #  1-IDSXP   #  2-VGS1P   #  8-IGSO    # 10-VGF    \n";

# Preserve the #s and spaces
@numaray = /\s*(\S+)\s+(\S+)\s+(#\s+\S+)\s+(#\s+\S+)\s+(#\s+\S+)\s+(#\s+\S+)/;
# Ignore the #s and spaces
@justnums = /\s*(\S+)\s+(\S+)\s+#\s+(\S+)\s+#\s+(\S+)\s+#\s+(\S+)\s+#\s+(\S+)/;

foreach (@numaray) { print "[$_]"; }
print "\n";

foreach (@justnums) { print "[$_]"; }
print "\n";

--Michael


Michael Leahy             Computer Systems Development Supervisor
michael.leahy@vt.edu      Educational Technologies, Mail Code 0232
540-231-3272              Old Security Building, Virginia Tech
540-231-5922 fax          Blacksburg, Virginia  24061

         Intellectual revolutions succeed when
         the old guard dies or retires. --Unknown



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch