url? ( predicate function )

Started by didi, June 13, 2007, 10:04:12 PM

Previous topic - Next topic

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 .

cormullion

#1
Perhaps you can write a regex that matches URLs. There's one here:



http://foad.org/~abigail/Perl/url2.html">//http://foad.org/~abigail/Perl/url2.html



or more precisely here:



http://foad.org/~abigail/Perl/url3.regex">//http://foad.org/~abigail/Perl/url3.regex



It made me laugh, too, not something that most regex expressions can do ... ;-)

didi

#2
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 ;-)

m35

#3
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">http://www.alh.net/newlisp/phpbb/viewtopic.php?t=1243

didi

#4
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.

cormullion

#5
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">//http://dev.perl.org/perl6/doc/design/apo/A05.html

didi

#6
BTW right now i found this astonishing report  :



http://swtch.com/~rsc/regexp/regexp1.html">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  ;-)