phpregex

regular expression for French characters


I need a function or a regular expression to validate strings which contain alpha characters (including French ones), minus sign (-), dot (.) and space (excluding everything else)

Thanks


Solution

  • /^[a-zàâçéèêëîïôûùüÿñæœ .-]*$/i
    

    Use of /i for case-insensitivity to make things simpler. If you don't want to allow empty strings, change * to +.