[NTLUG:Discuss] removing text: fighting tr and regex
Fred James
fredjame at fredjame.cnc.net
Thu Jul 6 07:42:14 CDT 2006
Victor Brilon wrote:
>On Jul 6, 2006, at 3:03 AM, Richard Geoffrion wrote:
>
>
>
>>echo "jdoe at example.com (John Doe)" | sed --expression s/\(.*?\)//g
>>
>>
>
>You're almost there:
>echo "jdoe at example.com (John Doe)" | sed -e s/\(.*\)//g
>
>To badly paraphrase "The Princess Bride": You keep using the ?
>qualifier, I don't think it does what you think it does :)
>
>If you truly want to use the ? qualifier to do what it's supposed to
>do (i.e., match the minimal number of chars), just use perl like this:
>echo "jdoe at example.com (John Doe)" | perl -n -e 's/\(.*?\)//g;print'
>
>Victor
>
>
>
Victor Brilon
It worked just fine in shell (for me anyway) by simply removing the '?'
echo "jdoe at example.com (John Doe)" | sed --expression s/\(.*\)//g
Regards
Fred James
More information about the Discuss
mailing list