newLISP Fan Club

Forum => Anything else we might add? => Topic started by: didi on June 13, 2007, 10:04:12 PM

Title: url? ( predicate function )
Post by: didi on June 13, 2007, 10:04:12 PM
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 .
Title:
Post by: cormullion on June 14, 2007, 10:07:22 AM
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 ... ;-)
Title:
Post by: didi on June 15, 2007, 11:49:55 PM
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 ;-)
Title:
Post by: m35 on June 16, 2007, 10:02:57 AM
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
Title:
Post by: didi on June 17, 2007, 12:45:13 AM
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.
Title:
Post by: cormullion on June 17, 2007, 01:33:56 AM
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
Title:
Post by: didi on June 25, 2007, 11:26:11 AM
BTW right now i found this astonishing report  :



http://swtch.com/~rsc/regexp/regexp1.html


QuoteThis 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  ;-)