How to help you with Regular Expressions?

25 views
Skip to first unread message

Gabor Szabo

unread,
Nov 28, 2012, 1:45:25 AM11/28/12
to pywe...@googlegroups.com
Hi,

I am currently attending the mobile web course of Ynon Perek
http://mobileweb.ynonperek.com/
and he encouraged us to build some random mobile application, and
upload to Google Play.
Actually he is even running a competition among the students for the
"most installed app".

So I started to write a tool to help people learn and practice Regular
Expressions.
I know quite a bit how Perl developers use Regular Expressions, but I
am not that familiar with the Python developers.
So I'd like to get some input from you, e.g. examples of what you
might think overuse of regexes.
If you don't use regexes much, I'd like to know why? Is that because
you don't know them or that you have
something which feels a better solution?

Of course, I'd also appreciate if you installed the application - that
might help me win the competition :)
but you might also give feedback.

It is available for Android:

http://regexmaven.com/
https://play.google.com/store/apps/details?id=com.regexmaven.app

regards
Gabor
ps. Oh and if you'd like to build web applications for mobile devices,
I'd recommend the course.

Emanuel Ilyayev

unread,
Nov 28, 2012, 5:03:08 AM11/28/12
to pywe...@googlegroups.com
Every django developer use regex for writing their URL dispatchers.
Another common use in django is writing validation rules for validating users' input...



--
You received this message because you are subscribed to the Google Groups "PyWeb-IL" group.
To post to this group, send email to pywe...@googlegroups.com.
To unsubscribe from this group, send email to pyweb-il+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyweb-il?hl=en.


Shlomi Fish

unread,
Nov 28, 2012, 12:26:06 PM11/28/12
to pywe...@googlegroups.com, ga...@szabgab.com
Hi Gabor,

On Wed, 28 Nov 2012 08:45:25 +0200
Gabor Szabo <ga...@szabgab.com> wrote:

> Hi,
>
> I am currently attending the mobile web course of Ynon Perek
> http://mobileweb.ynonperek.com/
> and he encouraged us to build some random mobile application, and
> upload to Google Play.
> Actually he is even running a competition among the students for the
> "most installed app".
>
> So I started to write a tool to help people learn and practice Regular
> Expressions.
> I know quite a bit how Perl developers use Regular Expressions, but I
> am not that familiar with the Python developers.
> So I'd like to get some input from you, e.g. examples of what you
> might think overuse of regexes.
> If you don't use regexes much, I'd like to know why? Is that because
> you don't know them or that you have
> something which feels a better solution?

my answer may be a bit off-topic for PyWeb-IL because it is not particularly
related to Web development with Python, but it answers your question which may
have been more appropriate on the main Python mailing list.

Anyway, while I don't have any particular aversion to using regular expressions
in Python (though I may sometimes overuse them), I noticed that when parsing
the output of fc-solve's solution ( see http://fc-solve.shlomifish.org/ ), the
PySolFC's developers (see http://pysolfc.sourceforge.net/ ) have chosen to
often avoid using regular expressions, and to split the string into words and
compare individual words. See:

https://github.com/shlomif/PySolFC/blob/4ee830ae2f93cfd3ce01381d55624acadeb75ce7/pysollib/hint.py

I added a regular expression match (out of convenience) in the lastest commit,
and don't understand why the rest of the pattern matching was not done using
regexes as well (maybe it was regular expression phobia).

This reminds me that I once talked with someone in the Haifa Linux Club who said
that regular expressions scared him away from Perl and that he used Tcl
instead. After I told him that Tcl had support for regular expressions he said
"Yeah, but no one uses them.". Then when he once told us that he wrote a
program in Perl because it used regular expressions a lot, I told him "But
Tcl has regular expressions!", and he said "Yeah, but it's better in Perl.".

I also recall that I heard from a few sources that SNOBOL->Icon's string
processing capabilities were better than Perl, and so I started learning Icon
from its online tutorial. From what I noticed one matches sub-patterns of text
to point two markers (start and end) and select the matching text. You can also
use regular expressions to match the place of the markers. From what I saw, it
may have been more capable and flexible than Perl's regular expressions (at
least not without some extra pos()/ \G / /g / /c logic), but it seemed much more
tedious.

Icon fell into obscurity due to the fact its creator got cancer or something
and was unable to promote or develop it further, and because it lacked many
general purpose programming features that Perl 5 (and later similar languages
such as Python or Ruby) had (including Object Oriented Programming).

Regards,

Shlomi Fish

>
> Of course, I'd also appreciate if you installed the application - that
> might help me win the competition :)
> but you might also give feedback.
>
> It is available for Android:
>
> http://regexmaven.com/
> https://play.google.com/store/apps/details?id=com.regexmaven.app
>
> regards
> Gabor
> ps. Oh and if you'd like to build web applications for mobile devices,
> I'd recommend the course.
>



--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
List of Text Processing Tools - http://shlom.in/text-proc

Larry Wall is lazy, impatient and full of hubris.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Shai Berger

unread,
Nov 28, 2012, 2:29:47 PM11/28/12
to pywe...@googlegroups.com, Shlomi Fish
On Wednesday 28 November 2012, Shlomi Fish wrote:
> [...] many general purpose programming features that Perl 5 (and later
> similar languages such as Python or Ruby) ...

For the record, Perl 5 (actually, 5.000, according to the Wikipedia article)
was released on October 17, 1994; Python 1.0 was released earlier that year.
The first public Python release (0.9.0) was in 1991, when Perl 5 was not even
planned...

> ... had (including Object Oriented Programming).

... and I vaguely remember someone quoting Larry Wall as saying that Perl's
object model is taken from Python.

Shai.

Shlomi Fish

unread,
Nov 28, 2012, 4:31:02 PM11/28/12
to pywe...@googlegroups.com, sh...@platonix.com
Hi Shai,

On Wed, 28 Nov 2012 21:29:47 +0200
Shai Berger <sh...@platonix.com> wrote:

> On Wednesday 28 November 2012, Shlomi Fish wrote:
> > [...] many general purpose programming features that Perl 5 (and later
> > similar languages such as Python or Ruby) ...
>
> For the record, Perl 5 (actually, 5.000, according to the Wikipedia article)
> was released on October 17, 1994; Python 1.0 was released earlier that year.
> The first public Python release (0.9.0) was in 1991, when Perl 5 was not even
> planned...

well, I was not speaking in terms of release dates, but rather the duration when
each language became extensively popular. I recall that when I started working
for cortext.co.il in 1996 (an early Israeli Web design shop), we were using
Perl 5 extensively and a variety of UNIX and UNIX-like machines, including
a Linux workstation, that was eventually converted to FreeBSD, because
FreeBSD was considered more mature at the time. Back then not too many people
have heard of Python, Ruby was not known outside Japan, Tcl was still quite
popular, and Apache was practically the only web-server one could use on UNIX in
their right mind. There were no real web frameworks, we wrote very bad HTML in
today's standards, the only available SQL databases were MiniSQL/mSQL (which now
no one remembers) which was proprietary/commercial sourceware, and
pre-fully-SQL Postgres (before it was called Postgres95 and then PostgreSQL),
etc. etc. Ah, the good old days. (Or not so good)

I remember an article somewhere about a Perl enthusiast's experiences in a
Python conference where he claimed that Zope was Python's killer app (again, it
emerged later, and now fell out of favour), and I believe that indicated
the indication of Python's raise to being more mainstream. And Ruby's rise
started only after Ruby-on-Rails was released years later.

>
> > ... had (including Object Oriented Programming).
>
> ... and I vaguely remember someone quoting Larry Wall as saying that Perl's
> object model is taken from Python.
>

Yes, see: http://www.perl.com/pub/2007/12/06/soto-11.html :

<<<<<
Python

After Tcl came Python, which in Guido's mind was inspired positively by ABC,
but in the Python community's mind was inspired negatively by Perl. I'm not
terribly qualified to talk about Python however. I don't really know much about
Python. I only stole its object system for Perl 5. I have since repented.
>>>>>

I don't mind languages "stealing" ideas from other languages, because
otherwise we would still be stuck with something like Fortran I.

My point was that by the time Icon was ready, it was not good enough to compete
with Perl 5 and later other languages, that release dates put aside, only
gained "mainstream" popularity and public awareness much later.

My random signature quote is relevant this time.

Regards,

Shlomi Fish

--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://shlom.in/sussman

There are at least 137 Larry Walls in the U.S., but only one that matters.
Reply all
Reply to author
Forward
0 new messages