[clue-tech] Re: regex smarties - what am I doing wrong?
Patrick H.
clue at feystorm.net
Wed Sep 3 16:14:54 MDT 2008
Oh, to handle text before its a tiny change
sed -e 's/.*\(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}\).*/\1/'
-------- Original Message --------
Subject: Re: [clue-tech] Re: regex smarties - what am I doing wrong?
From: David L. Willson <DLWillson at TheGeek.NU>
To: CLUE tech <clue-tech at cluedenver.org>
Date: Wednesday, September 03, 2008 4:01:16 PM
> On Wed, 03 Sep 2008 15:36:52 -0600, Patrick H. wrote
>
>> I think this is the sed you want
>> sed -e 's/\(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}\).*/\1/'
>>
>
> Closer, but not there yet.
>
> $ echo -e "98.76.54.32 Alice\nBob 123.45.67.89\nCarol or Dave 064.032.016.008\n"
> 98.76.54.32 Alice
> Bob 123.45.67.89
> Carol or Dave 064.032.016.008
>
> $ echo -e "98.76.54.32 Alice\nBob 123.45.67.89\nCarol or Dave 064.032.016.008\n" \
>
>> | sed -e 's/\(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}\).*/\1/'
>>
> 98.76.54.32
> Bob 123.45.67.89
> Carol or Dave 064.032.016.008
>
> As you can see, the Alice line is properly trimmed, but not the other lines. Now, I
> have two questions: Why don't the single quotes preserve the sed command properly
> without all the escaping of the special chars? And, why doesn't the second close-paren
> close the pattern-capture? Regexes are hard...
> _______________________________________________
> clue-tech mailing list
> clue-tech at cluedenver.org
> http://www.cluedenver.org/mailman/listinfo/clue-tech
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue-tech/attachments/20080903/37408c60/attachment.html
More information about the clue-tech
mailing list