On Feb 11, 4:21 pm, "J. mp" <joaomiguel.pere... / gmail.com> wrote:
> max size allowed is 30
> min size allowed is 5
>
> the follwoing chars are allowed :
> - _ . (Slash, undescore, perdiod)
>
> these chars are not allowed as start neither as ending char

/\A[a-z][a-z.-]{3,28}[a-z]\Z/i


Translated, that says:
* start at the beginning
* find any letter
* followed by 3-28 characters that are letters, periods, or hyphens
* followed by a letter
* follwed by the
* oh, and be case insensitive, please

Note that, per your exact instructions, this allows:
  u_s_e_r_n_a_m_e
  u____________________________e
  z._-_.z