LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-23-2012, 02:03 PM   #1
blueskynet
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Rep: Reputation: Disabled
Need help with this regex '^\*\|local7.*\s*\/[a-z]*'


Hi there,
As the title says, can someone explain to me what does that regex do? If possible, I would like to understand what each of these does.
\*

\|local7

.*

\s*

\/

[a-z]*

Thank you very much!
 
Old 05-23-2012, 02:58 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Can you please give us some context? Where did you dig this up, which tool/language
was it in? While 'regex' is a fairly well-known concept just about any tool you
touch that uses regex' will have a slightly different implementation.

If I assumed that the above was out of e.g., a perl snippet I'd break it up like so,
and would have to say that it's a weird (poorly written) regex:

Match anything that is either

Beginning of line, followed by any number of '\' followed by a backslash (the one behind the * doesn't make sense).
Code:
^\*\
or
Code:
|
the string local7 followed by any number of anything followed by any number of whitespace
followed by \/ followed by any number of lower case characters.
Code:
local7.*\s*\/[a-z]*

All up it makes little sense.



Cheers,
Tink
 
Old 05-23-2012, 07:04 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
Quote:
While 'regex' is a fairly well-known concept just about any tool you
touch that uses regex' will have a slightly different implementation.
Absolutely(!); check out this book for details http://regex.info/blog/2006-07-21/218.
I've read it a couple of times; very good.
 
Old 05-24-2012, 08:16 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,516

Rep: Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893
As the other's have said, it will depend on where this came from and I will show you why, as this is how I interpreted it:

Code:
^      - start of the line / string
\*     - an asterisk, escaped so as not to be confused
\|     - a pipe, also escaped
local7 - string
.*     - zero or more of any character
\s*    - zero or more spaces
\/     - forward slash, escaped like others above
[a-z]* - zero or more lower case letters
As you can see, without reference the outcome is quite different to Tink's above.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is LOCAL0 through LOCAL7 ? mrpc_cambodia Linux - Security 8 07-17-2015 05:50 PM
[SOLVED] differences between shell regex and php regex and perl regex and javascript and mysql golden_boy615 Linux - General 2 04-19-2011 01:10 AM
[SOLVED] what are local0 to local7 services in /etc/syslog.conf me_spearhead Linux - Server 3 03-14-2011 01:07 PM
Perl to find regex and print following 5 lines after regex casperdaghost Linux - Newbie 3 08-29-2010 08:08 PM
Question about syslog.conf. How can I exclude local7.notice from /var/log/messages? huntkey Linux - Server 2 04-25-2009 10:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration