isalpha

isalpha(c::Union{Char,AbstractString}) -> Bool

Tests whether a character is alphabetic, or whether this is true for all elements of a string. A character is classified as alphabetic if it belongs to the Unicode general category Letter, i.e. a character whose category code begins with 'L'.

Examples

  1. Check if a character is alphabetic:

    julia> isalpha('a')
    true
  2. Check if all characters in a string are alphabetic:

    julia> isalpha("hello")
    true
  3. Handle non-alphabetic characters in a string:

    julia> isalpha("hello, world!")
    false

    It returns false because the string contains non-alphabetic characters (',', ' ' and '!').

  4. Check if a character is alphabetic using a variable:

    julia> c = 'A'
    'A'
    
    julia> isalpha(c)
    true

    The variable c holds the character 'A', and isalpha returns true for alphabetic characters.

Common mistake example:

julia> isalpha(65)
ERROR: MethodError: no method matching isalpha(::Int64)

In this example, the input to the isalpha function is an integer instead of a character or string. It's important to provide a character or string as input to the function to avoid this error.

See Also

BigFloat, BigInt, Dict, eltype, fieldtype, Float32, Float64, IntSet, isa, isalnum, isalpha, isascii, iseltype, isequal, isgraph, isimmutable, isinteractive, isleaftype, isnull, ispunct, isspace, issubtype, keytype, Nullable, NullException, promote_type, typeintersect, typejoin, typemax, typemin, typeof, Val, valtype,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: