Page 1 of 1
url? ( predicate function )
Posted: Thu Jun 14, 2007 5:04 am
by didi
Is there a "url?" function to filter valid url's out of lists ?
I know the xml-parse functions shows url's in this way :
"url" "http://..." ...
but to get the url i must first look for "url" then i've to catch the element behind "url"
A "email-adress?" function would be nice, too - but ok, a bit programming by myself doesn't hurt .
Posted: Thu Jun 14, 2007 5:07 pm
by cormullion
Perhaps you can write a regex that matches URLs. There's one here:
http://foad.org/~abigail/Perl/url2.html
or more precisely here:
http://foad.org/~abigail/Perl/url3.regex
It made me laugh, too, not something that most regex expressions can do ... ;-)
Posted: Sat Jun 16, 2007 6:49 am
by didi
Thanks Cormullion !
After your hints i think i can reduce it to "http" - urls's .
To be honest i don't like regex, even if Lutz says it should be taught in kindergarten and it would be the best ..
- newLISP is nice , beautiful , easy useable, simple understandable, smart... Regex is none of them , Regex is UGLY !!
That page full of Regex shows it clear like glass, there is a need for a regex-english and english-regex translator , at best in newLISP , i'll think about it ;-)
Posted: Sat Jun 16, 2007 5:02 pm
by m35
Hi didi,
In case you hadn't seen it, Jeremy Dunn created something you may be interested in:
http://www.alh.net/newlisp/phpbb/viewtopic.php?t=1243
Posted: Sun Jun 17, 2007 7:45 am
by didi
No i hadn't seen that , thanks m35 !
That functional concept looks better than regex itself - why not an additional step forward ? if possible even more easier. At best with more clear text and selfexplaining .. if possible.
Posted: Sun Jun 17, 2007 8:33 am
by cormullion
I think there are some signs that people want to move away from the traditional 'regex' approach, although I'm not convinced that the new approach will be that much better. Throwing more punctuation at a problem isn't always the best solution...
http://dev.perl.org/perl6/doc/design/apo/A05.html
Posted: Mon Jun 25, 2007 6:26 pm
by didi
BTW right now i found this astonishing report :
http://swtch.com/~rsc/regexp/regexp1.html
This is a tale of two approaches to regular expression matching. One of them is in widespread use in the standard interpreters for many languages, including Perl. The other is used only in a few places, notably most implementations of awk and grep ...
and the other can be clearly faster !
PS: ok - i'm learning regex now , i want to have a good control about it ;-)