endswith(string, suffix | chars)

Returns true if string ends with suffix. If the second argument is a vector or set of characters, tests whether the last character of string belongs to that set.


  1. Check if a string ends with a specific suffix:

    julia> endswith("Hello World", "World")

    This example returns true because the string "Hello World" ends with the suffix "World".

  2. Check if a string ends with any of the given characters:

    julia> endswith("Julia", ['a', 'i'])

    Here, the function returns true because the last character of the string "Julia" is 'a', which is one of the characters provided.

  3. Handle case sensitivity:

    julia> endswith("julia", "JULIA"; ignorecase=true)

    By setting the ignorecase parameter to true, the function performs a case-insensitive check. In this example, it returns true because "julia" ends with "JULIA" regardless of case.

Common mistake example:

julia> endswith("Hello", "hello")

In this example, the function returns false because it performs a case-sensitive check by default. Make sure to consider case sensitivity when using endswith to avoid such mistakes.

See Also

ascii, base64decode, Base64DecodePipe, base64encode, Base64EncodePipe, bin, bits, bytestring, charwidth, chomp, chop, chr2ind, contains, endswith, escape_string, graphemes, ind2chr, iscntrl, istext, isupper, isvalid, join, lcfirst, lowercase, lpad, lstrip, normalize_string, num2hex, parseip, randstring, readuntil, replace, repr, rpad, rsplit, rstrip, search, searchindex, split, startswith, string, stringmime, strip, strwidth, summary, takebuf_string, ucfirst, unescape_string, uppercase, utf16, utf32, utf8, wstring,

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

Checking you are not a robot: