[newbie] Regular expressions (was: Vi vs Emacs)

2003-02-06 Thread Jan Wilson
* FemmeFatale [EMAIL PROTECTED] [030206 17:40]:
 Thx CM.  Question:  what are regular expressions ?  And sed?  Heard of 
 it... but no clue what it is... I'll look it up later.  The regular 
 expressions has me stumped though mostly.

Regular expressions are REALLY fun.  I saw recently that someone said
that regular expressions are to strings what math is to numbers.

I do a lot in Perl, and it has very powerful regex capabilities.
There are similar but (usually) slightly less capable regexes in
many GNU utilities and languages, including egrep, sed, awk, PHP,
and many others.

Using a Perl example (something I'm working on right now), if one line
of output from this command:

netstat -pe

produces:

tcp  37088  0 ahau.localdomain:33148  ltc002:x11  ESTABLISHED  judy
73301

(that's all on one line), then we can use:

/^tcp\s+\d+\s+\d+\s+(\w+)\.\w+:\d+\s+(\w+):x11\s+ESTABLISHED\s+(\w+)/

and then we can print out the three pieces I'm interested in:

printf %-9s  %-9s  %-9s\n, $1, $2, $3

to give me a listing of servers, LTSP workstations, and users.  This

ahau   ltc002 judy

is much easier to read than the original.

As another example, suppose you ask the user to confirm, and you want
to check for a positive response, like y or yes or yep or yeah or ok:

doaction() if /^(y|ye(s|p|ah)|ok)$/i;

Anyway, hope this gives you an idea.  Jeffrey E. F. Friedl's book,
Mastering Regular Expressions (O'Reilly) is a good reference, and
there are tutorials and such if you Google 'em.

-- 
Jan Wilson, SysAdmin _/*];  [EMAIL PROTECTED]
Corozal Junior College   |  |:'  corozal.com corozal.bz
Corozal Town, Belize |  /'  chetumal.com  linux.bz
Reg. Linux user #151611  |_/   Network, PHP, Perl, HTML



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [newbie] Regular expressions (was: Vi vs Emacs)

2003-02-06 Thread FemmeFatale
At 07:05 PM 2/6/2003 -0600, you wrote:

Snaffled gibberish spewed in email

Anyway, hope this gives you an idea.  Jeffrey E. F. Friedl's book,
Mastering Regular Expressions (O'Reilly) is a good reference, and
there are tutorials and such if you Google 'em.

--
Jan Wilson, SysAdmin


Heh well it doesn't help me any, but I'm sure it will help someone 
else.  To me thats all gibberish.  :)

IOW, I suck @ programming  logic.  Yay for learning disabilities! :)

-
FemmeFatale

Good Decisions You boss Made:
We'll do as you suggest and go with Linux. I've always liked that
character from Peanuts.

- Source: Dilbert



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



[newbie] Regular Expressions

2000-03-26 Thread Lane Lester

I keep running into references to "regular expressions" in different contexts.
Where can I learn about regular expressions?
-- 
Lane

Lane Lester / Madison County, Georgia USA
Using Linux to get where I want to go...




Re: [newbie] Regular Expressions

2000-03-26 Thread Rial Juan


Well, you can learn about them in the "perlre" manpage.

"man perlre", FYI.

On Mar 26 Lane Lester wrote:

 I keep running into references to "regular expressions" in different contexts.
 Where can I learn about regular expressions?
 

-- 

Rial Juanhttp://nighty.ulyssis.org
e-mail:  [EMAIL PROTECTED]
Belgiumtel:(++32) 89/856533
ulyssis system admininstrator   http://www.ulyssis.org

The little critters in nature; they don't know they're ugly.
That's very funny... A fly marying a bumble-bee...



Sign the petition at http://www.libranet.com/petition.html
Help bring us more Linux Drivers