[drupal-devel] call for arms: The Final URL regexp [tm]

Bèr Kessels berdrupal at tiscali.be
Tue Feb 15 15:13:24 UTC 2005


We currently have loads of web-url rexexping scattered over the place. A quick 
check_url($value) (core)
search ranking (core)
field_url.inc (flexinode)
weblink.module (various places)
url_filter.module (filters)
probalby more, like events.

I would really like it if some regexp-guru can give me a hand with creating a 
single regexp that can be used drupalwide. 
What i want is either one API finction that handles all [1] or two API 
functions [2]. I am working on the weblink module, but plan to make it much 
better useable by drupal and its modules (an API).

[1] all :
check_url($text = NULL, $full_text = NULL) 
   $text, if given, check if $text is a valid URL, return the valid url if   
   TRUE, otherwise return FALSE
   $full_text, if given, check the fulltext for occurring URLS, return an 
array with all found URLS: 
    $return[X] = array('text'=>$url_text, //optional text found in HTML 
                                   'local'=>$local_flag //if $base_domain == 

[2] two functions:
check_url($text = NULL, $full_text = NULL)  as above.
where $type is 'url', 'mailto' or 'html' (other suggestions?)
returns a string that can be used as regular expression in preg_replace to 
find a plain URL, mailto:url or an a href= URL. 

Any takers?

| Bèr Kessels | webschuur.com | website development |
| Turnhoutsebaan 34/3 | 2140 Antwerpen | België |
| IM: ber at jabber.org.uk | MSN: berkessels at gmx.net |
| pers: bler.webschuur.com | prof: www.webschuur.com |

More information about the drupal-devel mailing list