Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > regular expressions for beginners

Reply
Thread Tools

regular expressions for beginners

 
 
Jim
Guest
Posts: n/a
 
      01-07-2006
There's been a number of questions about regular expressions in recent
days.

The Ruby User's Guide has a small script to highlight regular
expression patterns. I found it quite helpful for visualizing regex's,
especially while learning them.

http://www.ruby-doc.org/docs/UsersGuide/rg/

 
Reply With Quote
 
 
 
 
Une bévue
Guest
Posts: n/a
 
      01-07-2006
Jim <(E-Mail Removed)> wrote:

>
> http://www.ruby-doc.org/docs/UsersGuide/rg/

i don' get colors even with the ansi termianl over MacOS X...

--
une bévue
 
Reply With Quote
 
 
 
 
Daniel Harple
Guest
Posts: n/a
 
      01-07-2006
Works here[1]. What is your $TERM set at?

[1] After changing:
str.gsub! re, "#{st}\\&#{en}" to
str.gsub!(/#{re}/, "#{st}\\&#{en}") # gsub takes a string /or/ =20
regular-expression

On Jan 7, 2006, at 4:08 PM, Une b=E9vue wrote:

> Jim <(E-Mail Removed)> wrote:
>
>>
>> http://www.ruby-doc.org/docs/UsersGuide/rg/

> i don' get colors even with the ansi termianl over MacOS X...
>
> --=20
> une b=E9vue
>




 
Reply With Quote
 
Une bévue
Guest
Posts: n/a
 
      01-07-2006
Daniel Harple <(E-Mail Removed)> wrote:

> str.gsub!(/#{re}/, "#{st}\\&#{en}")


thanks, right now i get reverse video for match.

i'm sure my Terminal works with ansi colors because recently i've tried
xml-smart "xpath_visual.rb" with term-ansicolor-0.0.4.

see for example <http://cjoint.com/data/bhvDrQHhrH.htm>
--
une bévue
 
Reply With Quote
 
Vladimir Agafonkin
Guest
Posts: n/a
 
      01-07-2006
Jim wrote:

> The Ruby User's Guide has a small script to highlight regular
> expression patterns. I found it quite helpful for visualizing regex's,
> especially while learning them.
>
> http://www.ruby-doc.org/docs/UsersGuide/rg/



There's also a small tool (GUI) bundled with Ruby Development Tools for
Eclipse that does just that. Quite useful.

--
Posted via http://www.ruby-forum.com/.


 
Reply With Quote
 
Gene Tani
Guest
Posts: n/a
 
      01-08-2006

Vladimir Agafonkin wrote:
> Jim wrote:
>
> > The Ruby User's Guide has a small script to highlight regular
> > expression patterns. I found it quite helpful for visualizing regex's,
> > especially while learning them.
> >
> > http://www.ruby-doc.org/docs/UsersGuide/rg/

>
>
> There's also a small tool (GUI) bundled with Ruby Development Tools for
> Eclipse that does just that. Quite useful.
>
> --
> Posted via http://www.ruby-forum.com/.


some other things that might help
http://www.weitz.de/regex-coach/
http://samuelfullman.com/team/php/to..._tester_p2.php
http://www.regular-expressions.info/python.html

but i think best is Friedl's Oreilly regular expression book

 
Reply With Quote
 
Chad Perrin
Guest
Posts: n/a
 
      01-09-2006
On Mon, Jan 09, 2006 at 06:08:11PM +0900, Gene Tani wrote:
>
> Vladimir Agafonkin wrote:
> > Jim wrote:
> >
> > > The Ruby User's Guide has a small script to highlight regular
> > > expression patterns. I found it quite helpful for visualizing regex's,
> > > especially while learning them.
> > >
> > > http://www.ruby-doc.org/docs/UsersGuide/rg/

> >
> >
> > There's also a small tool (GUI) bundled with Ruby Development Tools for
> > Eclipse that does just that. Quite useful.
> >
> > --
> > Posted via http://www.ruby-forum.com/.

>
> some other things that might help
> http://www.weitz.de/regex-coach/
> http://samuelfullman.com/team/php/to..._tester_p2.php
> http://www.regular-expressions.info/python.html
>


The clearest explanation I recall seeing was . . . I think it was
chapter seven in Learning Perl (I have 2nd Ed.: later editions might
have it in a different chapter for all I know). Yes, I know, it's Perl
and not Ruby -- but that doesn't mean it's not useful knowledge.

--
Chad Perrin [ CCD CopyWrite | http://ccd.apotheon.org ]

print substr("Just another Perl hacker", 0, -2);


 
Reply With Quote
 
Matthew Stott
Guest
Posts: n/a
 
      01-09-2006
------=_Part_10374_32530333.1136811773542
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

There is an excellent book from O'Reilly -
http://www.oreilly.com/catalog/regex2/
I've read it and it is by far and large the best regex tutorial available.

"Mastering Regular Expressions, Second Edition"

By Jeffrey E. F. Friedl
Second Edition July 2002
ISBN: 0-596-00289-0

-----------------------------------------------------

Full Description

Regular expressions are an extremely powerful tool for manipulating text an=
d
data. They have spread like wildfire in recent years, now offered as
standard features in Perl, Java, VB.NET and C# (and any language using the
NET Framework), PHP, Python, Ruby, Tcl, MySQL, awk, Emacs, and many other
popular tools and languages.

If you don't use regular expressions yet, you will discover in this book a
whole new world of mastery over your data. If you already use them, you'll
appreciate this book's unprecedented detail and breadth of coverage. If you
think you know all you need to know about regular expressions, this book is
a stunning eye-opener.

In spite their wide availability, flexibility, and unparalleled power,
regular expressions are frequently underutilized. Regular expressions allow
you to code complex and subtle text processing that you never imagined coul=
d
be automated. Regular expressions can save you time and aggravation. They
can be used to craft elegant solutions to a wide range of problems.

A command of regular expressions is an invaluable skill. Yet what is power
in the hands of an expert can be fraught with peril for the unwary.
Mastering Regular Expressions will help you navigate the minefield to
becoming an expert. Once you've mastered regular expressions, they'll becom=
e
an invaluable part of your toolkit. You will wonder how you ever got by
without them.

Mastering Regular Expressions, Second Edition has been thoroughly updated t=
o
include all the new features of Perl 5.8, as well as several other
languages, including Java, VB.NET, C#, Python, JavaScript, Tcl, and Ruby.
Written in the lucid, entertaining tone that made a complex, dry topic
crystal-clear to thousands of programmers, and sprinkled with solutions to
complex real-world problems, Mastering Regular Expressions offers a wealth
information that you can put to immediate use.

Topics include:


A comparison of features among different versions of many languages and
tools

How the regular expression engine works

Optimization (major savings available here!)

Matching just what you want, but not what you don't want

Sections and chapters on individual languages

------=_Part_10374_32530333.1136811773542--


 
Reply With Quote
 
Matthew Stott
Guest
Posts: n/a
 
      01-09-2006
------=_Part_10414_23151566.1136811967329
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

If you don't have access to the O'Reilly book, here are some regex resource=
s
found on digg.com.

http://www.crazygrrl.com/weav/reference.php3
http://www.regular-expressions.info/
http://gnosis.cx/publish/programming...pressions.html

------=_Part_10414_23151566.1136811967329--


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Regular Expressions in ASP.net Jay Douglas ASP .Net 3 11-03-2003 08:09 PM
Regular expressions mark Perl 4 10-28-2003 12:37 PM
perl regular expressions return last matched occurence? Dustin D. Perl 1 08-28-2003 01:51 AM
matching curly braces and regular expressions Dustin D. Perl 0 08-26-2003 11:18 PM
Add custom regular expressions to the validation list of available expressions Jay Douglas ASP .Net 0 08-15-2003 10:19 PM



Advertisments