From: Byron Rakitzis <byron@rakitzis.com>
To: jim.robinson@stanford.edu
Cc: sam-fans@hawkwind.utcs.toronto.edu
Subject: Re: shorter struct regex?
Date: Wed, 22 Mar 2000 19:05:47 -0500 [thread overview]
Message-ID: <200003230000.QAA24942@peanut.rakitzis.com> (raw)
> 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.
next reply other threads:[~2000-03-23 3:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-23 0:05 Byron Rakitzis [this message]
[not found] <rsc@plan9.bell-labs.com>
[not found] ` <200003230026.TAA06530@smtp3.fas.harvard.edu>
2000-03-23 15:19 ` James A. Robinson
-- strict thread matches above, loose matches on Subject: below --
2000-03-23 9:51 Bengt Kleberg
2000-03-18 5:24 James A. Robinson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200003230000.QAA24942@peanut.rakitzis.com \
--to=byron@rakitzis.com \
--cc=jim.robinson@stanford.edu \
--cc=sam-fans@hawkwind.utcs.toronto.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).