From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from proxy2.ba.best.com ([206.184.139.14]) by hawkwind.utcs.utoronto.ca with SMTP id <28302>; Wed, 22 Mar 2000 22:02:58 -0500 Received: from peanut.rakitzis.com (dynamic59.pm01.san-mateo.best.com [205.149.174.59]) by proxy2.ba.best.com (8.9.3/8.9.2/best.out) with ESMTP id QAA18816; Wed, 22 Mar 2000 16:02:20 -0800 (PST) Received: (from byron@localhost) by peanut.rakitzis.com (8.8.7/8.8.7) id QAA24942; Wed, 22 Mar 2000 16:00:35 -0800 From: Byron Rakitzis Message-Id: <200003230000.QAA24942@peanut.rakitzis.com> To: jim.robinson@stanford.edu Subject: Re: shorter struct regex? Cc: sam-fans@hawkwind.utcs.toronto.edu Date: Wed, 22 Mar 2000 19:05:47 -0500 > public Hashtable return() > throws MissingRequiredValueException > { > String[] req = > { > "order-id", "amount" > }; > > String[] opt = > { > "card-number", "card-exp", "card-name", "card-address", "card-city", > "card-zip" > }; > return processRequest("return", req, opt); > } > .... > > I wanted to expand the elements of the arrays to one per line. This is > what I used: > > ,x/{\n([^}]+\n)+ }/x/, +[^\n]/x/ +/c/\n / > > Is there way I could of done this with less work? > > > Jim Jim, One of my favorite tricks is a pipe to fmt. Fmt will preserve leading whitespace (well, it can be trickier than that since fmt tries to do pharagraph indentation as well). To force one-column output, you only need to do "fmt -1", which strictly speaking denotes one-CHARACTER output, but fmt does the right thing. So: "card-number", "card-exp", "card-name", "card-address", "card-city", "card-zip" piped through "fmt -1" gives (at least on this linux machine): "card-number", "card-exp", "card-name", "card-address", "card-city", "card-zip" Of course, you still have the problem about selecting the braced-in regions without using the mouse. Perhaps another out-of-the-box approach is to pipe your entire code through a C beautifier. "indent" has so many options, I would be surprised if array initializers one-per-line was not one of them. Byron.