[TriLUG] bash scripting - formatting and verifying input
porter at trilug.org
Thu Feb 28 21:03:05 EST 2008
> Here's a question/challenge - how would you modify this to
> verify that each octet is between zero and 255?
A similar question popped up in an interview (fortunately, I
was on the giving side of this one).
I usually take the stance that this SHOULD be done with a split
and an explicit check of each digit. If that kind of function
is crammed into a regexp, then it quickly turns in to BFM (black
If speed is essential, and regexp is declared to be the way to
go, then the BFM should be accompanied by generous helpings of
Because in the end, (in most applications) I don't care how many
cycles my multi-GHz CPU has to spend on the problem. I am much
more concerned with how much time my DEVELOPERS have to spend
maintaining the code after it is in place.
More information about the TriLUG