LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   what does this regular expression do? (https://www.linuxquestions.org/questions/programming-9/what-does-this-regular-expression-do-760397/)

smeezekitty 10-07-2009 04:31 PM

what does this regular expression do?
 
what does this do? :
Code:

[U|LI]N[U|I]X

pixellany 10-07-2009 04:52 PM

Well....

It depends on how it is used---right? What is it supposed to do?

smeezekitty 10-07-2009 04:54 PM

i really dont know
i found it when i digging thru my harddrive

pixellany 10-07-2009 05:04 PM

What does this mean?:
[U|LI]

and how is it different from?:
[ULI]

sycamorex 10-07-2009 05:20 PM

Isn't | the operator that matches either argument?

[LI|U]N - would match LIN or UN
[I|U]X - IX or UX

If I'm not mistaken, this search pattern would match either LINUX or UNIX

gzunk 10-07-2009 05:24 PM

And LINIX and UNUX :)

bgeddy 10-07-2009 05:27 PM

Quote:

If I'm not mistaken, this search pattern would match either LINUX or UNIX
.. and LINIX or UNUX surely ?

smeezekitty 10-07-2009 05:27 PM

thank you
its anoying to come by somthing but nnot know what it does

sycamorex 10-07-2009 05:38 PM

Quote:

Originally Posted by gzunk (Post 3711538)
And LINIX and UNUX :)

LOL

sycamorex 10-07-2009 06:02 PM

Actually, it's even worse than that. Pixellany was right.

Code:

[U|LI]N

It would match any word that contains the capital letter U or L or I followed by N. The same goes for the second part of the pattern.
For example, it would match:
ADFAEDUNFAFAFDDIX, etc.

sycamorex 10-07-2009 06:12 PM

Code:

bash-3.1$ ls | grep -E '[LI|U]N[U|I]X'
ADDFUNUX
INIX
LINIX
LINUX
UNIX
UNUX
UNUXFOD
bash-3.1$ ls | grep -E '(LI|U)N(U|I)X'
ADDFUNUX
LINIX
LINUX
UNIX
UNUX
UNUXFOD
bash-3.1$ ls | grep -E '^(LI|U)N(U|I)X$'
LINIX
LINUX
UNIX
UNUX
bash-3.1$ ls | grep -E '^(LINU|UNI)X$'
LINUX
UNIX



All times are GMT -5. The time now is 10:57 AM.