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

Re(2): [MacPerl] Regular Expression Definition



At 20:52 -0800 11/6/98, Mark Yannuzzi wrote:
>I was unaware that whitespace had this specific a definition, i.e., that
>you cannot have two adjacent instances of whitespace...this is helpful to
>know...specifically,
>
>>  *  any of the whitespace characters is other than a space (blank)
>   -  no, all '^' are spaces, any other "invisible" character is as
>indicated.
>>  *  the number of whitespace characters between the fields varies
>   -  yes.
>>  *  the fields are bounded within certain column positions
>   -  a little unclear are what you mean, the extrema are the beginning
>      <ASCII 10> and the ending \n...I think, however, that the columns
>      that begin with a '#' may be limited to 12 characters (leaving a
>      single space between the preceeding and following column.  The
>      spacing between before and after the "YY,XX" and "BIN" columns
>      are constant.
>
>I was trying to do this with a single use of the "split" function, which
>is what prompted my initial e-mail...perhaps this is not possible.

<\010> YY,XX   BIN #  1-IDSXP   #  2-VGS1P   #  8-IGSO    # 10-VGF    \n
      ^     ^^^   ^ ^^       ^^^ ^^       ^^^ ^^      ^^^^ ^      ^^^^

You don't say whether the "10" in "<ASCII 10>" is octal or decimal.  It
makes no difference, as far as I can tell, but it is good to be precise.

I am sure that someone could come up with a more elegant way to solve
this problem, but here is a simple and robust method that _should_ work
(it's science fiction, however, as I haven't tried it! :-)

  chomp($line);                         # strip off newline
  $line = substr($line, 2);             # strip off leading junk
  @fields = split($line);               # split on whitespace
  $array[0] =  fields[0];               # "YY,XX"
  $array[1] =  fields[1];               # "BIN"
  $array[2] = "fields[2]  fields[3]";   # "#  1-IDSXP"
  $array[3] = "fields[4]  fields[5]";   # "#  2-VGS1P"
  $array[4] = "fields[6]  fields[7]";   # "#  8-IGSO"
  $array[5] = "fields[8] fields[9]";    # "# 10-VGF"








Rich Morin:          rdm@cfcl.com, +1 650-873-7841, http://www.ptf.com/~rdm
Prime Time Freeware: info@ptf.com, +1 408-433-9662, http://www.ptf.com
MacPerl: http://www.ptf.com/macperl,   http://www.ptf.com/ptf/products/MPPE
MkLinux: http://www.mklinux.apple.com, http://www.ptf.com/ptf/products/MKLP



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