[aklug] Re: sed regex help needed

From: David J. Weller-Fahy <dave-lists-aklug@weller-fahy.com>
Date: Sat Nov 14 2009 - 19:30:33 AKST

* Lee <lee@afabco.org> [2009-11-14 18:10 -0500]:
> I'm trying to use sed to extract an arbitrary length substring that
> begins with KB and ends with - . That's a space-dash.
I'm making the following assumptions.
- The substring does not contain the sequence "KB" or " -".
- The format of the surrounding line is not set, in other words the only
  format we are sure of is the first two characters and last two
  characters of the substring. Everything else on the line could be
  anything (except another substring duplicating this format, else this
  could fall apart).

Given those assumptions, the following would work.

        |sed 's/^.*\(KB.*\) -.*$/\1/'

Hope that helps.

Regards,

-- 
dave [ please don't CC me ]
-- Attached file included as plaintext by Ecartis --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)
iEYEARECAAYFAkr/g+kACgkQzahokXOb2UzGNACeOxZUI/BBiKCWaWNpDhIFM30f
ksIAn0nmrULOPLe/NSLNz6v+zRCBwzcz
=KJ+E
-----END PGP SIGNATURE-----
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sat Nov 14 19:32:17 2009

This archive was generated by hypermail 2.1.8 : Sat Nov 14 2009 - 19:32:17 AKST