[NTLUG:Discuss] removing text: fighting tr and regex
    Richard Geoffrion 
    ntlug at rain4us.net
       
    Thu Jul  6 03:03:10 CDT 2006
    
    
  
Given a sample text string of:
jdoe at example.com (John Doe), jane at example.com (Jane Doe)
and a regex of
\(.*?\)   [or maybe \((.*?)\)]
what I would expect the regex to match would be any number of any characters
inside and including the parenthesis.
I'm having a rough time testing that theory as I can't properly manipulate
that text with any bash command that I know of.  I've tried tr and sed and
the following commands don't work.  Oh, I can get 'tr' to strip out the
parenthesis, but not the text between them?  Any suggestions?
echo "jdoe at example.com (John Doe)" | sed --expression s/\(.*?\)//g  #does
nothing
echo "jdoe at example.com (John Doe)" | tr -d '\(.*?\)' #removes the
parenthesis only (with or without the single quotes)
I've looked at (g)awk but don't see how it can be used for what I'm wanting.
Is there a better utility to use or is there something wrong with the regex
I'm trying to use in sed?
-- 
Richard
    
    
More information about the Discuss
mailing list