On Tue, Oct 18, 2011 at 02:04:38PM -0400, David Kramer wrote:
> Thanks for all your help.  The only real problem I'm having at this
> point is matching square brackets.  Since square brackets need to be
> escaped even when maching a set of characters, I don't know how to tell
> it to match an open square bracket then characters in a set, then a
> close square bracket.
> 
> This is what I mean: Lets say I want to match [ followed by lower case
> letters or a period, followed by ].
> MATCH:  [net.thekramers.foo]
> NOT A MATCH:  net.thekramers.foo
> NOT A MATCH:  [net.thekramers.Foo!]

You can use a character class that just contains the bracket, e.g.:

$ cat junk.txt
blah [foo.derek.bar] blah nada
blah [foo.derek.bar!] blah nada
blah foo.derek.bar blah nada
$ grep '[[][a-z.]\+[]]' junk.txt 
blah [foo.derek.bar] blah nada
$ sed 's/[[][a-z.]\+[]]/[address redacted]/g' junk.txt
blah [address redacted] blah nada
blah [foo.derek.bar!] blah nada
blah foo.derek.bar blah nada


-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.

_______________________________________________
Discuss mailing list
[email protected]
http://lists.blu.org/mailman/listinfo/discuss

Reply via email to