[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regex lesson (again)
You are correct, sir. It appears to be cutting out lines that have only
whitespace or whitespace followed by a comment. [:space:] is the POSIX
regexp class that's equivilent to Perl's \s (one whitespace char). It's
inside of another set of brackets because they're supposed to be used
inside of character classes...
--Danny
On Thu, Apr 19, 2001 at 09:22:26PM -0500, charles@lunarmedia.net wrote:
> i am reading through the init script for iptables, and i am not certain
> how this regex is doing what its doing:
>
> grep -v "^[[:space:]]*#"
>
> or this one
>
> grep -v '^[[:space:]]*$'
>
> the grep -v i understand, but what is going on with this
>
> ^[[:space:]]*#
>
> ^ beginning
> [ grouping
> [:space:] is this some sort of way to indicate
> whitespace or something?
> ] end of group
> * any number of this grouping
> # a literal pound
>
> i am pretty sure that this is just a grep for any line that has some/no
> whitespace and then a literal # character. so, i assume this is grepping
> for lines that do not begin with a comment. i am just curious as to know
> how exactly its working.
> the second regex looks to be grepping for lines that are strictly
> whitespace (or in the case of -v lines that are not strictly whitespace.)
>
> thanks
-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.