<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Grant - check out Russ Cox's web page on this very subject: <a href="https://streaklinks.com/BaglRcA5OeZepwiX_AELMUI5/https%3A%2F%2Fswtch.com%2F%7Ersc%2Fregexp%2F">Implementing Regular Expressions</a></div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aY2xlbWNAY2NjLmNvbQ%3D%3D&type=zerocontent&guid=06995b37-76b6-4506-be95-cceee4aef424"><font color="#ffffff" size="1">ᐧ</font></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 2, 2023 at 1:55 PM Grant Taylor via COFF <<a href="mailto:coff@tuhs.org">coff@tuhs.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'd like some thoughts ~> input on extended regular expressions used <br>
with grep, specifically GNU grep -e / egrep.<br>
<br>
What are the pros / cons to creating extended regular expressions like <br>
the following:<br>
<br>
    ^\w{3}<br>
<br>
vs:<br>
<br>
    ^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)<br>
<br>
Or:<br>
<br>
    [ :[:digit:]]{11}<br>
<br>
vs:<br>
<br>
    ( 1| 2| 3| 4| 5| 6| 7| 8| <br>
9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31) <br>
(0|1|2)[[:digit:]]:(0|1|2|3|4|5)[[:digit:]]:(0|1|2|3|4|5)[[:digit:]]<br>
<br>
I'm currently eliding the 61st (60) second, the 32nd day, and dealing <br>
with February having fewer days for simplicity.<br>
<br>
For matching patterns like the following in log files?<br>
<br>
    Mar  2 03:23:38<br>
<br>
I'm working on organically training logcheck to match known good log <br>
entries.  So I'm *DEEP* in the bowels of extended regular expressions <br>
(GNU egrep) that runs over all logs hourly.  As such, I'm interested in <br>
making sure that my REs are both efficient and accurate or at least not <br>
WILDLY badly structured.  The pedantic part of me wants to avoid <br>
wildcard type matches (\w), even if they are bounded (\w{3}), unless it <br>
truly is for unpredictable text.<br>
<br>
I'd appreciate any feedback and recommendations from people who have <br>
been using and / or optimizing (extended) regular expressions for longer <br>
than I have been using them.<br>
<br>
Thank you for your time and input.<br>
<br>
<br>
<br>
-- <br>
Grant. . . .<br>
unix || die<br>
<br>
</blockquote></div>