views:

39

answers:

3

I would like to write a PLSQL function that returns true if the domain name I pass is valid.

I should use regular expression, but I don't know how to do this.

declare  
  ignore boolean;  
begin  
  isDomainSyntaxOk('www.laclasse.com'); --> should return true.   
  isDomainSyntaxOk('www.la classe.com'); --> should return false because of the space char.  
end;  

Any ideas ?

A: 

My regex skills are weak, so I'm hoping that someone comes along and fixes this:

create or replace
FUNCTION IS_VALID_DOMAIN (p_DOMAIN IN VARCHAR2) RETURN BOOLEAN IS
BEGIN
  RETURN REGEXP_LIKE(p_DOMAIN, '^[a-z0-9][a-z.0-9]*[a-z]$');
end;
Adam Hawkes