Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Looking for help with regular expressions- not Python Specific

Reply
Thread Tools

Looking for help with regular expressions- not Python Specific

 
 
Tony C
Guest
Posts: n/a
 
      01-08-2004
I'm writing a python program which uses regular expressions, but I'm
totally new to regexps.

I've got Kuchling's "Regexp HOWTO", "Mastering Regular Expresions" by
Oreilly, and have access to online stuff too.

But I would like to find a mailing list or newsgroup where I can ask
questions about regexps (when things don't work), not specifically
dealing with Python. When I have Python-regexp questions, I'll post
them here of course.

Googling around didn't produce any useable results (of course if I new
how to use regexps, I could probably do more-intelligent searches)


thanks
 
Reply With Quote
 
 
 
 
Joe Francia
Guest
Posts: n/a
 
      01-08-2004
Tony C wrote:
> I'm writing a python program which uses regular expressions, but I'm
> totally new to regexps.
>
> I've got Kuchling's "Regexp HOWTO", "Mastering Regular Expresions" by
> Oreilly, and have access to online stuff too.
>
> But I would like to find a mailing list or newsgroup where I can ask
> questions about regexps (when things don't work), not specifically
> dealing with Python. When I have Python-regexp questions, I'll post
> them here of course.
>
> Googling around didn't produce any useable results (of course if I new
> how to use regexps, I could probably do more-intelligent searches)
>


First, be sure you actually need regexes. See if you can achieve the
same results using string methods. String methods are faster to run,
easier to write, and much easier to debug.

If you still need regex:
The O'Reilly book is a great source. You also may want to check out
Kodos for interactively testing & debugging regexes -
http://kodos.sourceforge.net

And always keep this in mind:
'Some people, when confronted with a problem, think "I know, I'll use
regular expressions." Now they have two problems.'
--Jamie Zawinski, comp.lang.emacs
 
Reply With Quote
 
 
 
 
Roy Smith
Guest
Posts: n/a
 
      01-08-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Tony C) wrote:
> But I would like to find a mailing list or newsgroup where I can ask
> questions about regexps (when things don't work), not specifically
> dealing with Python. When I have Python-regexp questions, I'll post
> them here of course.


I don't know of any regex-specific newsgroups or mailing lists, but most
old unix hands are pretty good at them, so asking in comp.unix.questions
might be worth trying. Perl makes extensive use of regex, so I'll bet
you'll find some regex gurus on comp.lang.perl too.

Try doing a search on groups.google.com for regex and see what
newsgroups pop up the most with recent dates, then ask your questions
there. Keep in mind that there are many different regex libraries out
there, and they don't all accept exactly the same syntax. Python and
Perl use the same library (I believe).

But, on the other hand, we're a pretty friendly group on
comp.lang.python, and I know there's a bunch of regex wizards who hang
out here as well, so why not just ask here.

One Python-specific tip is to get into the habit of ALWAYS using the r''
style raw strings for regex. It makes life so much simplier.

Joe Francia <(E-Mail Removed)> wrote:
> First, be sure you actually need regexes. See if you can achieve the
> same results using string methods. String methods are faster to run,
> easier to write, and much easier to debug.


Regex's are an extremely powerful tool, and anybody who's serious about
programming (especially if you do text processing) should have a solid
mastery of them. That being said, Joe is certainly right about them not
always being the best tool for the job. Chainsaws and scalpels are both
useful cutting tools, but hardly interchangable in all applications.
Regex's can lead to extremely fast and compact code, but then can also
lead to stuff which is impossible for anybody to understand 6 months
later.

Also, Joe's comment that string methods are faster to run is a
half-truth. Regex's get compiled. If you use the all-in-one step regex
methods, you compile the expression every time you use it. Compiling is
expensive. But, if you pre-compile the expression, using it is very
fast. Doing the compile step once, and re-using the result can be very
fast. A single regex that looks for a complex pattern may well be
faster than a series of string methods tied together with conditional
logic. Your mileage may vary, so if speed is important to you, try
different ways and profile it.

In any case, for the vast majority of stuff, speed is just not an issue,
and you should pick your weapon based more on clarity and simplicity of
the resulting code than on raw speed.
 
Reply With Quote
 
David K. Wall
Guest
Posts: n/a
 
      01-08-2004
Roy Smith <(E-Mail Removed)> wrote:

> I don't know of any regex-specific newsgroups or mailing lists, but most
> old unix hands are pretty good at them, so asking in comp.unix.questions
> might be worth trying. Perl makes extensive use of regex, so I'll bet
> you'll find some regex gurus on comp.lang.perl too.


Please use comp.lang.perl.misc instead. comp.lang.perl "officially" does not
exist, as it was rmgrouped in August 1995. Some carelessly-administered news
servers still carry it, unfortunately.

alt.perl is another possibility, and is perhaps a bit looser about what is
considered on-topic for the newsgroup, but clpm tends to have more
knowledgeable people. (although some people frequent both c.l.p.m and a.p)

--
David Wall
 
Reply With Quote
 
=?ISO-8859-1?Q?Bernard_Delm=E9e?=
Guest
Posts: n/a
 
      01-08-2004
You might find the redemo.py script real handy when investigating
regexes. It should live in the Tools subdirectory of your python
install (and requires tkinter).

 
Reply With Quote
 
Samuel Walters
Guest
Posts: n/a
 
      01-09-2004
|Thus Spake Tony C On the now historical date of Wed, 07 Jan 2004 21:14:52
-0800|

> I'm writing a python program which uses regular expressions, but I'm
> totally new to regexps.
>
> I've got Kuchling's "Regexp HOWTO", "Mastering Regular Expresions" by
> Oreilly, and have access to online stuff too.


It may be more than you're looking for, but regular expressions are a nice
compact encoding of finite state machines. If you really, really, really
want to grok regexp's and are willing to make an investment of time in it,
then you are best to understand fsm's. Searching for understandable
material could be tough going. You'll come across a lot of cryptic
mathematical papers. My tip is that you'll start turning up papers that
include references to push down automata and turing machines. These are
more powerful versions of finite state machines, but not directly related
to regexps. Skip over them. Really, anyone with a solid understanding of
programming fundamentals should be able to understand fsm's. I would
point you to some resources, but I haven't got any handy.

Happy Hunting.

Sam Walters.

P.S. If you look deeper into finite state machines, push down automata,
turing machines and the lambda calculus, your soul will merge with the
deeper zen of computer programming. Deep understanding of these four
concepts (whether that understanding is conscious or unconscious) is what
separates good programmers from truly great ones. I suggest "Godel,
Escher, Bach" by Douglas Hofstadter as a good, but dizzying, introduction
to this territory.


--
Never forget the halloween documents.
http://www.opensource.org/halloween/
""" Where will Microsoft try to drag you today?
Do you really want to go there?"""

 
Reply With Quote
 
JanC
Guest
Posts: n/a
 
      01-09-2004
Joe Francia <(E-Mail Removed)> schreef:

> You also may want to check out
> Kodos for interactively testing & debugging regexes -
> http://kodos.sourceforge.net


An alternative to Kodos is Kiki:
<http://project5.freezope.org/kiki/>
(uses wxPython while Kodos uses pyQT)

--
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9
 
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
XML parsing problem finding a specific element in a specific place mazdotnet ASP .Net 2 10-02-2009 10:07 AM
Parsing DOM to search specific tags with specific custom attribute William FERRERES Javascript 7 07-09-2007 08:11 PM
Is ViwState Page-Specific or UserControl-Specific =?Utf-8?B?SmF2?= ASP .Net 2 08-16-2006 09:30 PM
redirect traffic on specific ip to specific interface mimiseh Cisco 3 06-05-2005 09:14 PM
How do you make sure a frameset is loaded? I'm trying to open a frameset in a new window which shows a specific html page in a specific frame ck388 Javascript 1 09-24-2003 08:32 PM



Advertisments