I've got a regEx which is working fine, but it seems, somehow, inelegant. I've been pouring through documentation to find a better way to write this, but I haven't come up with anything yet.
While I've wrapped my mind around the basics, I'm always striving to get better, so I thought I'd ask: is there a better way to do this?
Here is the (single line) I'm matching against:
[Tue Apr 20 04:51:19 2004] [error] [client 68.103.45.137] File does no +t exist: /home/virtual/site6/fst/var/www/html/robots.txt
And here is my regEx:
\[client[\w\s.]{12,16}\](.*?$)
$1 captures everything which is the actual error, in this examples case "File does not exist .... " to the end.
I had thought there must be a way to say "match the very last ] you find, til the end of the line, but I haven't been able to figure it out. Just seems wasteful to me to have to match all that client 102.102.102.102 stuff to grab the part I actually want.
So, anyone care to enlighten me on the more elegant solution? Eagerly awaiting your Monkish reponses ...
theAcolyte
In reply to Is there a better way to write this RegEx? by theAcolyte
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |