From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Help parsing a file from one regex to another
Date: Fri, 08 Jul 2005 17:16:27 +0000 [thread overview]
Message-ID: <1050708171627.ZM16747@candle.brasslantern.com> (raw)
In-Reply-To: <20050708073037.GB9744@localhost.localdomain>
On Jul 8, 5:30pm, Doug Kearns wrote:
} Subject: Re: Help parsing a file from one regex to another
}
} > I am trying to parse a range of data out of a file from one regular
} > expression up to another. The input starts with `^@main::FLAGS' and
} > goes up to the next `)' I am using awk right now, but it is *ugly*
}
} flags=( ${=${${${(f)"$(<$tmp_file)"}[(r)@main::FLAGS*,(r)\);]}#*\"}//[^[:upper:][:blank:]]/} )
That only works if the closing paren is on a line by itself, I think.
You need (r)*\); in the subscript expression, maybe even (r)*\);* if there
may be other stuff following the close-paren.
Also, that expression won't work if you replace FLAGS with PRIORITIES,
because (r)*\); always matches the end of the FLAGS assignment, which is
before the beginning of the PRIORITIES assignment.
To extract just the line(s) of interest from the file with sed:
sed -n -e '/^@main::FLAGS.*)/{p;q;}' -e '/^@main::FLAGS/,/)/p'
If you know that the close paren is never on the same line as the @main
then you can eliminate the first -e expression.
So to put the whole thing together:
flags=( ${${$(sed -n -e '/^@main::FLAGS.*)/{p;q;}' -e '/^@main::FLAGS/,/)/p' <$tmp_file)}//[^[:upper:]]/} )
shift flags # Throw away the word "FLAGS" from @main::FLAGS
next prev parent reply other threads:[~2005-07-08 17:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-08 6:36 Travis Spencer
2005-07-08 7:30 ` Doug Kearns
2005-07-08 17:16 ` Bart Schaefer [this message]
2005-07-08 19:24 ` Travis Spencer
2005-07-09 6:41 ` Doug Kearns
2005-07-09 17:16 ` Bart Schaefer
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=1050708171627.ZM16747@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@sunsite.dk \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).