473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Looking for help with regular expressions- not Python Specific

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
Jul 18 '05 #1
6 2033
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
Jul 18 '05 #2
ca*******@yahoo.com (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 <usenet@-OBFUSCATED-joefrancia.com> 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.
Jul 18 '05 #3
Roy Smith <ro*@panix.com> 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
Jul 18 '05 #4
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).

Jul 18 '05 #5
|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?"""

Jul 18 '05 #6
Joe Francia <usenet@-OBFUSCATED-joefrancia.com> 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
Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Steve | last post by:
Hello, I am writing a script that calls a URL and reads the resulting HTML into a function that strips out everthing and returns ONLY the links, this is so that I can build a link index of various...
2
by: Sehboo | last post by:
Hi, I have several regular expressions that I need to run against documents. Is it possible to combine several expressions in one expression in Regex object. So that it is faster, or will I...
2
by: news.microsoft.com | last post by:
I need help design a reg exp. I am parsing an html file to get the input values, here is one example <input VALUE="Staff Writer" size=60 type="text" name="author"> Can I grab the value "Staff...
13
by: The Cleaning Wonder Boy | last post by:
Could someone please explain to me what the (?<Key> and (?<Value> are in the following Regex expression? This gets relative links in an HTML string (file). ...
4
by: Jéjé | last post by:
Hi, I have a file which contain 1 pair of values by line like: Name1=Value1 = I nned to store these pair of values in a sortedlist. So the result expected for the 2 samples lines is: Key ...
3
by: Zach | last post by:
I'm writing an app which is going to rely extremely heavily on the usage of regular expressions. I'm reading the docs but having trouble wrapping my head around some of this since it's all fairly...
3
by: ProvoWallis | last post by:
Hi, I'm looking for a little advice about regular expressions. I want to capture a string of text that falls between an opening squre bracket and a closing square bracket (e.g., "") but I've run...
23
by: codefire | last post by:
Hi, I am trying to get a regexp to validate email addresses but can't get it quite right. The problem is I can't quite find the regexp to deal with ignoring the case james..kirk@fred.com, which...
1
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
9
by: Rene | last post by:
I'm trying to basically remove chunks of html from a page but I must not be doing my regular expression correctly. What i'm trying with no avail. $site = preg_replace("/<!DOCTYPE(.|\s)*<div...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.