Graphs
Andreas Ericsson
ae at op5.se
Mon Oct 25 18:30:35 CEST 2004
martinus.nel at scarceskills.com wrote:
> Michael,
>
> Since you are successful with it, may we lesser beings view some of your
> templates, especially the regexp ones ? :)
>
> Just in case someone here thinks that I am desperate ... yes I am, I just
> can't seem to get the hang of the regular expressions :-)
>
It's really pretty straightforward, so long as you remember a couple of
simple rules;
[abc] denotes a character class and matches any of the characters a, b or c.
* means 'match any or none of the previous character (class)'
. means 'match any char'.
There are others as well, but those are the ones that doesn't require
odd escaping. Fling around with grep and sed a bit and I'm sure you'll
get the idea. For instance, try;
grep '.*foo.*'
and then type a lot of gibberish. The lines you type with 'foo'
somewhere in them will match and be printed twice.
Regex matching with substitutions works the same way, but it has
delimiters at the beginning, the end and between the match and the
substitution. The delimiter can be any char, but / and , and # and | are
commonly seen in shell-scripts.
thus
sed 's/foo/bar/'
(gibberish goes here)
will replace (the leading s in the sed command means substitute) foo
with bar in any text you type.
Fool around a bit. It's the best way to learn, and you'll learn more as
you go along. Should all else fail, pick up a book on perl. It's main
feature is just that, regexing, so they're bound to be covered in detail.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Lead Developer
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list