* Re: Regular Expression Problem
2004-06-12 6:34 Regular Expression Problem Park Lee
@ 2004-06-12 8:09 ` Luke Kenneth Casson Leighton
2004-06-12 8:38 ` Russell Coker
1 sibling, 0 replies; 3+ messages in thread
From: Luke Kenneth Casson Leighton @ 2004-06-12 8:09 UTC (permalink / raw)
To: Park Lee; +Cc: selinux
On Fri, Jun 11, 2004 at 11:34:26PM -0700, Park Lee wrote:
> Hi,
>
> In the file_contexts file, I found some regular expressions. I studied them for a while, but still can't understand them well.
>
> For example: /var(/.*)
>
> As I know: '.' stands for any character;
> Let's suppose '.' now stands for character 'a'.
> then '/var(/.*)' can mean:
> '/var/a','/var/aa','/var/aaa','/var/aaaa','/var/aaaaa', ... ...
>
> But now, If I have a file or directory named 'abc' in directory '/var' (i.e.,
> /var/abc). How can it match '/var(/.*)' ?
well, i don't pretend to understand regular expressions either:
they are one of the most obscure nasty amazingly compact hang-overs
from the days when computers didn't have enough space to store
wordey programs or programming languages.
i think you'll find that the regular expression you are referring to
is "/var(/.*)?" note the question mark which means it's optional.
dot means any one character, and star means zero or more characters.
so dot star means "one or more characters".
obtuse as it is, can i recommend that you read up on several
sources of regular expressions, for example "man regex"
and also
http://www.google.com/search?q=regular+expressions
remember we said google is your friend? well we REALLY MEANT IT!
if you don't know about something, put some random words into
google, first.
THEN if you can't find an answer, and it's definitely SE/Linux
related, ask.
sincerely,
l.
--
--
Information I post is with honesty, integrity, and the expectation that
you will take full responsibility for acting on the information contained,
and that, should you find it to be flawed or even mildly useful, you
will act with both honesty and integrity in return - and tell me.
--
<a href="http://lkcl.net"> lkcl.net </a> <br />
<a href="mailto:lkcl@lkcl.net"> lkcl@lkcl.net </a> <br />
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Regular Expression Problem
2004-06-12 6:34 Regular Expression Problem Park Lee
2004-06-12 8:09 ` Luke Kenneth Casson Leighton
@ 2004-06-12 8:38 ` Russell Coker
1 sibling, 0 replies; 3+ messages in thread
From: Russell Coker @ 2004-06-12 8:38 UTC (permalink / raw)
To: Park Lee; +Cc: selinux
On Sat, 12 Jun 2004 16:34, Park Lee <parklee_sel@yahoo.com> wrote:
> As I know: '.' stands for any character;
> Let's suppose '.' now stands for character 'a'.
> then '/var(/.*)' can mean:
> '/var/a','/var/aa','/var/aaa','/var/aaaa','/var/aaaaa', ... ...
The '*' is evaluated before the '.'. So /var(/.*) expands to '/var/.',
'/var/..', '/var/...', and then in each case the '.' characters are expanded
independently.
See regex(7) for all the details.
--
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/ Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/ My home page
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread