Re: [RndTbl] RegEx help needed (sed?)
.* Is greedy, sed "s/^.*\/\([^_@]*\).*$/\1/" Kevin McGregor <kevin.a.mcgregor@gmail.com> wrote:
_______________________________________________ Roundtable mailing list Roundtable@muug.ca https://muug.ca/mailman/listinfo/roundtable
Without a .* except for the end could be done with multiples: sed "s/^[^\/]*//" /tmp/input | sed "s/^\///" | sed 's/[_\@].*//' On 2016-11-29 10:11 AM, Paul Sierks wrote:
.* Is greedy,
sed "s/^.*\/\([^_@]*\).*$/\1/"
Kevin McGregor <kevin.a.mcgregor@gmail.com> wrote:
I'm using sed to massage some input. Specifically, I have input lines like
aaaaaaaaaa/BBBBB_ccc@00000 or aaaaaaaaaa/BBBBB@00000
and I want the output to always be
BBBBB
I've got most of it, but I can't figure out how to get rid of anything at the end of the line after EITHER the underscore OR the '@' (including either of those two characters).
Is this possible in one expression in sed? I can do it with piping the input through sed twice but I was wondering if one pass would do it. Currently I'm using
sed "s/^.*\/\(.*\)[_@].*$/\1/"
Which doesn't get rid of the "_ccc" when it appears, just the "@00000".
Suggestions?
_______________________________________________ Roundtable mailing list Roundtable@muug.ca https://muug.ca/mailman/listinfo/roundtable
Oh, I see what you're doing. Thanks, that works! On Tue, Nov 29, 2016 at 10:11 AM, Paul Sierks <psierks@sierkstech.net> wrote:
.* Is greedy,
sed "s/^.*\/\([^_@]*\).*$/\1/"
Kevin McGregor <kevin.a.mcgregor@gmail.com> wrote:
I'm using sed to massage some input. Specifically, I have input lines like
aaaaaaaaaa/BBBBB_ccc@00000 or aaaaaaaaaa/BBBBB@00000
and I want the output to always be
BBBBB
I've got most of it, but I can't figure out how to get rid of anything at the end of the line after EITHER the underscore OR the '@' (including either of those two characters).
Is this possible in one expression in sed? I can do it with piping the input through sed twice but I was wondering if one pass would do it. Currently I'm using
sed "s/^.*\/\(.*\)[_@].*$/\1/"
Which doesn't get rid of the "_ccc" when it appears, just the "@00000".
Suggestions?
_______________________________________________ Roundtable mailing list Roundtable@muug.ca https://muug.ca/mailman/listinfo/roundtable
participants (3)
-
Kevin McGregor -
Paul Sierks -
Robert Keizer