Zoltán Kócsi wrote:
> Regexp is a fairly complex beast and probably quite unnatural unless
> you have some sort of programming training. In that sense it is
> questionable how useful regexps are in a generic word processor for the
> general public, but if you happen to have regexp experience by using
> tools like perl, awk, grep, lex and alike then you can express quite
> complex searches efficiently.

OK, first of all there is a famous cite of Jamie Zawinski (on
<http://www.jwz.org/hacks/marginal.html>): `(Some people, when confronted
with a problem, think ``I know, I'll use regular expressions.'' Now they
have two problems.)' There is something about that :-). Nevertheless, I use
regexps quite often and when limited to useful level of complexity, they
could be quite useful. But, it *IS* difficult to use them and learning
curve *IS* quite steep. Perl (probably the best and fastest implementation
of RE currently available) has four manpages for RE (perlrequick,
perlretut, perlre, and perlreref).

Sideshow for serious geeks: first read this
http://www.tbray.org/ongoing/When/200x/2004/08/22/PJre,
http://www.tbray.org/ongoing/When/200x/2004/08/26/PJre2, and
http://www.tbray.org/ongoing/When/200x/2005/11/20/Regex-Promises.
Explanation of this mystery is here
http://perlmonks.org/index.pl?node_id=502408 (apparently Perl has support
for so complex REs where all other RE implementations break down). And BTW
I do not use Perl if I don't have to (much prefer Python, but apparently
here Perl is better than anybody else).

Back to our main presentation tonight: there seems to be two ways how to
deal with REs in OpenOffice.org (and elsewhere). Either you will ignore
them, or you will bite the bullet and learn them. Actually, the first way
is not so ridiculous as it seems to be. As it was repeated many times by
vi-people (vi-family editors don't have anything else than RE for
searching): "plain string is valid RE and as such will be evaluated" (let's
ignore case sensitivity of REs for a moment); i.e., when you are searching
for "moron", you can just put "moron" into your RE field and everything
will work as expected. Being in this position you are not worse off, then
if there were no REs at all.

However, learning REs is not so difficult as it seems to be from looking at
some really advanced examples (yeah, sure you want some examples; this RE
in Python syntax r"(\d{3})\D*(\d{3})\D*(\d{4})\D*(\d*)$" parses US phone
numbers and returns their parts in different fields; courtesy of Mark
Pilgrim from <http://www.diveintopython.org>). You can begin for starters
with just something so simple as "colou?r" and even that will be incredibly
helpful. Just throw "regular expression tutorial" into your friendly Google
and you will find a lot of stuff which can help. You have to be aware only
of couple of things---first of all, that there are at least two
incompatible lines of REs living well "in wild" (for more info on that read 
<http://en.wikipedia.org/wiki/Regular_expression> on Wikipedia). The best
way how to deal with this is to learn just the type of RE used in the
application you're going to use (for OOo I just randomly stumbled upon
<http://homepage.ntlworld.com/garryknight/linux/ooregexp.html>). BTW, you
could just go to Help "List of Regular Expression", but it is really just a
reference material, which is not enough for somebody who doesn't what's
going on.

The last thing---thank you, OOo developers, that you have included full-size
REs into OOo and not something crippled like "wildcards" in M$ Word (which
is just a small subset of REs packaged for non-geeks). This and other
things (XSLT filters and scripting, albeit the latter is severly
underdocumented) made OOo much more than just another free office
suite-like (there are others), but serious platform for doing things in the
proper geek-like way. Thanks!

So that's my small epistole about RE (you can find it also on
http://www.ceplovi.cz/matej/blog/computer/ooo-re-2005-11-27-17-21.html).

Blessings,

Matej
-- 
Matej Cepl, http://www.ceplovi.cz/matej/blog/
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
 
The American Republic will endure, until politicians realize they
can bribe the people with their own money.
    -- Alexis de Tocqueville



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to