<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#0050d0">
Oh, to handle text before its a tiny change<br>
<pre wrap="">sed -e 's/.*\(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}\).*/\1/'</pre>
<br>
<br>
-------- Original Message --------<br>
Subject: Re: [clue-tech] Re: regex smarties - what am I doing wrong?<br>
From: David L. Willson <a class="moz-txt-link-rfc2396E" href="mailto:DLWillson@TheGeek.NU"><DLWillson@TheGeek.NU></a><br>
To: CLUE tech <a class="moz-txt-link-rfc2396E" href="mailto:clue-tech@cluedenver.org"><clue-tech@cluedenver.org></a><br>
Date: Wednesday, September 03, 2008 4:01:16 PM<br>
<blockquote cite="mid:20080903215836.M66639@TheGeek.NU" type="cite">
<pre wrap="">On Wed, 03 Sep 2008 15:36:52 -0600, Patrick H. wrote
</pre>
<blockquote type="cite">
<pre wrap="">I think this is the sed you want
sed -e 's/\(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}\).*/\1/'
</pre>
</blockquote>
<pre wrap=""><!---->
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" \
</pre>
<blockquote type="cite">
<pre wrap="">| sed -e 's/\(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}\).*/\1/'
</pre>
</blockquote>
<pre wrap=""><!---->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
<a class="moz-txt-link-abbreviated" href="mailto:clue-tech@cluedenver.org">clue-tech@cluedenver.org</a>
<a class="moz-txt-link-freetext" href="http://www.cluedenver.org/mailman/listinfo/clue-tech">http://www.cluedenver.org/mailman/listinfo/clue-tech</a>
</pre>
</blockquote>
<br>
<br>
</body>
</html>