# [Strings](#lib-strings)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L341-L358)
```julia
==(a::AbstractString, b::AbstractString) -> Bool
```
Test whether two strings are equal character by character (technically, Unicode code point by code point). Should either string be a [`AnnotatedString`](#Base.AnnotatedString) the string properties must match too.
**Examples**
```julia-repl
julia> "abc" == "abc"
true

julia> "abc" == "αβγ"
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L323-L338)
```julia
cmp(a::AbstractString, b::AbstractString) -> Int
```
Compare two strings. Return `0` if both strings have the same length and the character at each index is the same in both strings. Return `-1` if `a` is a prefix of `b`, or if `a` comes before `b` in alphabetical order. Return `1` if `b` is a prefix of `a`, or if `b` comes before `a` in alphabetical order (technically, lexicographical order by Unicode code points).
**Examples**
```julia-repl
julia> cmp("abc", "abc")
0

julia> cmp("ab", "abc")
-1

julia> cmp("abc", "ab")
1

julia> cmp("ab", "ac")
-1

julia> cmp("ac", "ab")
1

julia> cmp("α", "a")
1

julia> cmp("b", "β")
-1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L279-L311)
```julia
lpad(s, n::Integer, p::Union{AbstractChar,AbstractString}=' ') -> String
```


# [Strings](#lib-strings)
Stringify `s` and pad the resulting string on the left with `p` to make it `n` characters (in [`textwidth`](#Base.Unicode.textwidth)) long. If `s` is already `n` characters long, an equal string is returned. Pad with spaces by default.
**Examples**
```julia-repl
julia> lpad("March", 10)
"     March"
```
In Julia 1.7, this function was changed to use `textwidth` rather than a raw character (codepoint) count.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L452-L466)
```julia
rpad(s, n::Integer, p::Union{AbstractChar,AbstractString}=' ') -> String
```
Stringify `s` and pad the resulting string on the right with `p` to make it `n` characters (in [`textwidth`](#Base.Unicode.textwidth)) long. If `s` is already `n` characters long, an equal string is returned. Pad with spaces by default.
**Examples**
```julia-repl
julia> rpad("March", 20)
"March               "
```
In Julia 1.7, this function was changed to use `textwidth` rather than a raw character (codepoint) count.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L484-L498)
```julia
findfirst(pattern::AbstractString, string::AbstractString)
findfirst(pattern::AbstractPattern, string::String)
```
Find the first occurrence of `pattern` in `string`. Equivalent to [`findnext(pattern, string, firstindex(s))`](../arrays/#Base.findnext-Tuple%7BAny,%20Integer%7D).
**Examples**


# [Strings](#lib-strings)
```julia-repl
julia> findfirst("z", "Hello to the world") # returns nothing, but not printed in the REPL

julia> findfirst("Julia", "JuliaLang")
1:5
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/search.jl#L105-L119)
```julia
findnext(pattern::AbstractString, string::AbstractString, start::Integer)
findnext(pattern::AbstractPattern, string::String, start::Integer)
```
Find the next occurrence of `pattern` in `string` starting at position `start`. `pattern` can be either a string, or a regular expression, in which case `string` must be of type `String`.
The return value is a range of indices where the matching sequence is found, such that `s[findnext(x, s, i)] == x`:
`findnext("substring", string, i)` == `start:stop` such that `string[start:stop] == "substring"` and `i <= start`, or `nothing` if unmatched.
**Examples**
```julia-repl
julia> findnext("z", "Hello to the world", 1) === nothing
true

julia> findnext("o", "Hello to the world", 6)
8:8

julia> findnext("Lang", "JuliaLang", 2)
6:9
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/search.jl#L293-L318)
```julia
findnext(ch::AbstractChar, string::AbstractString, start::Integer)
```
Find the next occurrence of character `ch` in `string` starting at position `start`.
This method requires at least Julia 1.3.
**Examples**
```julia-repl
julia> findnext('z', "Hello to the world", 1) === nothing
true

julia> findnext('o', "Hello to the world", 6)
8
```


# [Strings](#lib-strings)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/search.jl#L321-L337)
```julia
findlast(pattern::AbstractString, string::AbstractString)
```
Find the last occurrence of `pattern` in `string`. Equivalent to [`findprev(pattern, string, lastindex(string))`](../arrays/#Base.findprev-Tuple%7BAny,%20Integer%7D).
**Examples**
```julia-repl
julia> findlast("o", "Hello to the world")
15:15

julia> findfirst("Julia", "JuliaLang")
1:5
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/search.jl#L365-L379)
```julia
findlast(ch::AbstractChar, string::AbstractString)
```
Find the last occurrence of character `ch` in `string`.
This method requires at least Julia 1.3.
**Examples**
```julia-repl
julia> findlast('p', "happy")
4

julia> findlast('z', "happy") === nothing
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/search.jl#L400-L416)
```julia
findprev(pattern::AbstractString, string::AbstractString, start::Integer)
```
Find the previous occurrence of `pattern` in `string` starting at position `start`.
The return value is a range of indices where the matching sequence is found, such that `s[findprev(x, s, i)] == x`:
`findprev("substring", string, i)` == `start:stop` such that `string[start:stop] == "substring"` and `stop <= i`, or `nothing` if unmatched.
**Examples**


# [Strings](#lib-strings)
```julia-repl
julia> findprev("z", "Hello to the world", 18) === nothing
true

julia> findprev("o", "Hello to the world", 18)
15:15

julia> findprev("Julia", "JuliaLang", 6)
1:5
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/search.jl#L611-L633)
```julia
occursin(needle::Union{AbstractString,AbstractPattern,AbstractChar}, haystack::AbstractString)
```
Determine whether the first argument is a substring of the second. If `needle` is a regular expression, checks whether `haystack` contains a match.
**Examples**
```julia-repl
julia> occursin("Julia", "JuliaLang is pretty cool!")
true

julia> occursin('a', "JuliaLang is pretty cool!")
true

julia> occursin(r"a.a", "aba")
true

julia> occursin(r"a.a", "abba")
false
```
See also [`contains`](#Base.contains).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/search.jl#L676-L698)
```julia
occursin(haystack)
```
Create a function that checks whether its argument occurs in `haystack`, i.e. a function equivalent to `needle -> occursin(needle, haystack)`.
The returned function is of type `Base.Fix2{typeof(occursin)}`.
This method requires Julia 1.6 or later.
**Examples**
```julia-repl
julia> search_f = occursin("JuliaLang is a programming language");

julia> search_f("JuliaLang")
true

julia> search_f("Python")
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/search.jl#L702-L723)


# [Strings](#lib-strings)
```julia
reverse(s::AbstractString) -> AbstractString
```
Reverses a string. Technically, this function reverses the codepoints in a string and its main utility is for reversed-order string processing, especially for reversed regular-expression searches. See also [`reverseind`](../arrays/#Base.reverseind) to convert indices in `s` to indices in `reverse(s)` and vice-versa, and `graphemes` from module `Unicode` to operate on user-visible "characters" (graphemes) rather than codepoints. See also [`Iterators.reverse`](../iterators/#Base.Iterators.reverse) for reverse-order iteration without making a copy. Custom string types must implement the `reverse` function themselves and should typically return a string with the same type and encoding. If they return a string with a different encoding, they must also override `reverseind` for that string type to satisfy `s[reverseind(s,i)] == reverse(s)[i]`.
**Examples**
```julia-repl
julia> reverse("JuliaLang")
"gnaLailuJ"
```
The examples below may be rendered differently on different systems. The comments indicate how they're supposed to be rendered
Combining characters can lead to surprising results:
```julia-repl
julia> reverse("ax̂e") # hat is above x in the input, above e in the output
"êxa"

julia> using Unicode

julia> join(reverse(collect(graphemes("ax̂e")))) # reverses graphemes; hat is above x in both in- and output
"ex̂a"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/substring.jl#L145-L180)


# [Strings](#lib-strings)
```julia
replace([io::IO], s::AbstractString, pat=>r, [pat2=>r2, ...]; [count::Integer])
```
Search for the given pattern `pat` in `s`, and replace each occurrence with `r`. If `count` is provided, replace at most `count` occurrences. `pat` may be a single character, a vector or a set of characters, a string, or a regular expression. If `r` is a function, each occurrence is replaced with `r(s)` where `s` is the matched substring (when `pat` is a `AbstractPattern` or `AbstractString`) or character (when `pat` is an `AbstractChar` or a collection of `AbstractChar`). If `pat` is a regular expression and `r` is a [`SubstitutionString`](#Base.SubstitutionString), then capture group references in `r` are replaced with the corresponding matched text. To remove instances of `pat` from `string`, set `r` to the empty `String` (`""`).
The return value is a new string after the replacements. If the `io::IO` argument is supplied, the transformed string is instead written to `io` (returning `io`). (For example, this can be used in conjunction with an [`IOBuffer`](../io-network/#Base.IOBuffer) to re-use a pre-allocated buffer array in-place.)
Multiple patterns can be specified, and they will be applied left-to-right simultaneously, so only one pattern will be applied to any character, and the patterns will only be applied to the input text, not the replacements.
Support for multiple patterns requires version 1.7.
The `io::IO` argument requires version 1.10.
**Examples**


# [Strings](#lib-strings)
```julia-repl
julia> replace("Python is a programming language.", "Python" => "Julia")
"Julia is a programming language."

julia> replace("The quick foxes run quickly.", "quick" => "slow", count=1)
"The slow foxes run quickly."

julia> replace("The quick foxes run quickly.", "quick" => "", count=1)
"The  foxes run quickly."

julia> replace("The quick foxes run quickly.", r"fox(es)?" => s"bus\1")
"The quick buses run quickly."

julia> replace("abcabc", "a" => "b", "b" => "c", r".+" => "a")
"bca"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L886-L932)
```julia
eachsplit(str::AbstractString, dlm; limit::Integer=0, keepempty::Bool=true)
eachsplit(str::AbstractString; limit::Integer=0, keepempty::Bool=false)
```
Split `str` on occurrences of the delimiter(s) `dlm` and return an iterator over the substrings. `dlm` can be any of the formats allowed by [`findnext`](../arrays/#Base.findnext-Tuple%7BAny,%20Integer%7D)'s first argument (i.e. as a string, regular expression or a function), or as a single character or collection of characters.
If `dlm` is omitted, it defaults to [`isspace`](#Base.Unicode.isspace).
The optional keyword arguments are:
-   `limit`: the maximum size of the result. `limit=0` implies no maximum (default)
-   `keepempty`: whether empty fields should be kept in the result. Default is `false` without a `dlm` argument, `true` with a `dlm` argument.
See also [`split`](#Base.split).
The `eachsplit` function requires at least Julia 1.8.
**Examples**


# [Strings](#lib-strings)
```julia-repl
julia> a = "Ma.rch"
"Ma.rch"

julia> b = eachsplit(a, ".")
Base.SplitIterator{String, String}("Ma.rch", ".", 0, true)

julia> collect(b)
2-element Vector{SubString{String}}:
 "Ma"
 "rch"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L516-L550)
```julia
eachrsplit(str::AbstractString, dlm; limit::Integer=0, keepempty::Bool=true)
eachrsplit(str::AbstractString; limit::Integer=0, keepempty::Bool=false)
```
Return an iterator over `SubString`s of `str`, produced when splitting on the delimiter(s) `dlm`, and yielded in reverse order (from right to left). `dlm` can be any of the formats allowed by [`findprev`](../arrays/#Base.findprev-Tuple%7BAny,%20Integer%7D)'s first argument (i.e. a string, a single character or a function), or a collection of characters.
If `dlm` is omitted, it defaults to [`isspace`](#Base.Unicode.isspace), and `keepempty` default to `false`.
The optional keyword arguments are:
-   If `limit > 0`, the iterator will split at most `limit - 1` times before returning the rest of the string unsplit. `limit < 1` implies no cap to splits (default).
-   `keepempty`: whether empty fields should be returned when iterating Default is `false` without a `dlm` argument, `true` with a `dlm` argument.
Note that unlike [`split`](#Base.split), [`rsplit`](#Base.rsplit) and [`eachsplit`](#Base.eachsplit), this function iterates the substrings right to left as they occur in the input.
See also [`eachsplit`](#Base.eachsplit), [`rsplit`](#Base.rsplit).


# [Strings](#lib-strings)
This function requires Julia 1.11 or later.
**Examples**
```julia-repl
julia> a = "Ma.r.ch";

julia> collect(eachrsplit(a, ".")) == ["ch", "r", "Ma"]
true

julia> collect(eachrsplit(a, "."; limit=2)) == ["ch", "Ma.r"]
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L613-L648)
```julia
split(str::AbstractString, dlm; limit::Integer=0, keepempty::Bool=true)
split(str::AbstractString; limit::Integer=0, keepempty::Bool=false)
```
Split `str` into an array of substrings on occurrences of the delimiter(s) `dlm`. `dlm` can be any of the formats allowed by [`findnext`](../arrays/#Base.findnext-Tuple%7BAny,%20Integer%7D)'s first argument (i.e. as a string, regular expression or a function), or as a single character or collection of characters.
If `dlm` is omitted, it defaults to [`isspace`](#Base.Unicode.isspace).
The optional keyword arguments are:
-   `limit`: the maximum size of the result. `limit=0` implies no maximum (default)
-   `keepempty`: whether empty fields should be kept in the result. Default is `false` without a `dlm` argument, `true` with a `dlm` argument.
See also [`rsplit`](#Base.rsplit), [`eachsplit`](#Base.eachsplit).
**Examples**
```julia-repl
julia> a = "Ma.rch"
"Ma.rch"

julia> split(a, ".")
2-element Vector{SubString{String}}:
 "Ma"
 "rch"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L708-L736)


# [Strings](#lib-strings)
```julia
rsplit(s::AbstractString; limit::Integer=0, keepempty::Bool=false)
rsplit(s::AbstractString, chars; limit::Integer=0, keepempty::Bool=true)
```
Similar to [`split`](#Base.split), but starting from the end of the string.
**Examples**
```julia-repl
julia> a = "M.a.r.c.h"
"M.a.r.c.h"

julia> rsplit(a, ".")
5-element Vector{SubString{String}}:
 "M"
 "a"
 "r"
 "c"
 "h"

julia> rsplit(a, "."; limit=1)
1-element Vector{SubString{String}}:
 "M.a.r.c.h"

julia> rsplit(a, "."; limit=2)
2-element Vector{SubString{String}}:
 "M.a.r.c"
 "h"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L747-L775)
```julia
strip([pred=isspace,] str::AbstractString) -> SubString
strip(str::AbstractString, chars) -> SubString
```
Remove leading and trailing characters from `str`, either those specified by `chars` or those for which the function `pred` returns `true`.
The default behaviour is to remove leading and trailing whitespace and delimiters: see [`isspace`](#Base.Unicode.isspace) for precise details.
The optional `chars` argument specifies which characters to remove: it can be a single character, vector or set of characters.
See also [`lstrip`](#Base.lstrip) and [`rstrip`](#Base.rstrip).
The method which accepts a predicate function requires Julia 1.2 or later.
**Examples**
```julia-repl
julia> strip("{3, 5}\n", ['{', '}', '\n'])
"3, 5"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L421-L444)


# [Strings](#lib-strings)
```julia
lstrip([pred=isspace,] str::AbstractString) -> SubString
lstrip(str::AbstractString, chars) -> SubString
```
Remove leading characters from `str`, either those specified by `chars` or those for which the function `pred` returns `true`.
The default behaviour is to remove leading whitespace and delimiters: see [`isspace`](#Base.Unicode.isspace) for precise details.
The optional `chars` argument specifies which characters to remove: it can be a single character, or a vector or set of characters.
See also [`strip`](#Base.strip) and [`rstrip`](#Base.rstrip).
**Examples**
```julia-repl
julia> a = lpad("March", 20)
"               March"

julia> lstrip(a)
"March"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L351-L374)
```julia
rstrip([pred=isspace,] str::AbstractString) -> SubString
rstrip(str::AbstractString, chars) -> SubString
```
Remove trailing characters from `str`, either those specified by `chars` or those for which the function `pred` returns `true`.
The default behaviour is to remove trailing whitespace and delimiters: see [`isspace`](#Base.Unicode.isspace) for precise details.
The optional `chars` argument specifies which characters to remove: it can be a single character, or a vector or set of characters.
See also [`strip`](#Base.strip) and [`lstrip`](#Base.lstrip).
**Examples**
```julia-repl
julia> a = rpad("March", 20)
"March               "

julia> rstrip(a)
"March"
```


# [Strings](#lib-strings)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L386-L409)
```julia
startswith(s::AbstractString, prefix::Union{AbstractString,Base.Chars})
```
Return `true` if `s` starts with `prefix`, which can be a string, a character, or a tuple/vector/set of characters. If `prefix` is a tuple/vector/set of characters, test whether the first character of `s` belongs to that set.
See also [`endswith`](#Base.endswith), [`contains`](#Base.contains).
**Examples**
```julia-repl
julia> startswith("JuliaLang", "Julia")
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L16-L30)
```julia
startswith(io::IO, prefix::Union{AbstractString,Base.Chars})
```
Check if an `IO` object starts with a prefix, which can be either a string, a character, or a tuple/vector/set of characters. See also [`peek`](../io-network/#Base.peek).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L81-L86)
```julia
startswith(prefix)
```
Create a function that checks whether its argument starts with `prefix`, i.e. a function equivalent to `y -> startswith(y, prefix)`.
The returned function is of type `Base.Fix2{typeof(startswith)}`, which can be used to implement specialized methods.
The single argument `startswith(prefix)` requires at least Julia 1.5.
**Examples**
```julia-repl
julia> startswith("Julia")("JuliaLang")
true

julia> startswith("Julia")("Ends with Julia")
false
```


# [Strings](#lib-strings)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L166-L186)
```julia
startswith(s::AbstractString, prefix::Regex)
```
Return `true` if `s` starts with the regex pattern, `prefix`.
`startswith` does not compile the anchoring into the regular expression, but instead passes the anchoring as `match_option` to PCRE. If compile time is amortized, `occursin(r"^...", s)` is faster than `startswith(s, r"...")`.
See also [`occursin`](#Base.occursin) and [`endswith`](#Base.endswith).
This method requires at least Julia 1.2.
**Examples**
```julia-repl
julia> startswith("JuliaLang", r"Julia|Romeo")
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/regex.jl#L308-L329)
```julia
endswith(s::AbstractString, suffix::Union{AbstractString,Base.Chars})
```
Return `true` if `s` ends with `suffix`, which can be a string, a character, or a tuple/vector/set of characters. If `suffix` is a tuple/vector/set of characters, test whether the last character of `s` belongs to that set.
See also [`startswith`](#Base.startswith), [`contains`](#Base.contains).
**Examples**
```julia-repl
julia> endswith("Sunday", "day")
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L42-L56)
```julia
endswith(suffix)
```
Create a function that checks whether its argument ends with `suffix`, i.e. a function equivalent to `y -> endswith(y, suffix)`.


# [Strings](#lib-strings)
The returned function is of type `Base.Fix2{typeof(endswith)}`, which can be used to implement specialized methods.
The single argument `endswith(suffix)` requires at least Julia 1.5.
**Examples**
```julia-repl
julia> endswith("Julia")("Ends with Julia")
true

julia> endswith("Julia")("JuliaLang")
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L143-L163)
```julia
endswith(s::AbstractString, suffix::Regex)
```
Return `true` if `s` ends with the regex pattern, `suffix`.
`endswith` does not compile the anchoring into the regular expression, but instead passes the anchoring as `match_option` to PCRE. If compile time is amortized, `occursin(r"...$", s)` is faster than `endswith(s, r"...")`.
See also [`occursin`](#Base.occursin) and [`startswith`](#Base.startswith).
This method requires at least Julia 1.2.
**Examples**
```julia-repl
julia> endswith("JuliaLang", r"Lang|Roberts")
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/regex.jl#L340-L361)
```julia
contains(haystack::AbstractString, needle)
```
Return `true` if `haystack` contains `needle`. This is the same as `occursin(needle, haystack)`, but is provided for consistency with `startswith(haystack, needle)` and `endswith(haystack, needle)`.
See also [`occursin`](#Base.occursin), [`in`](../collections/#Base.in), [`issubset`](../collections/#Base.issubset).
**Examples**


# [Strings](#lib-strings)
```julia-repl
julia> contains("JuliaLang is pretty cool!", "Julia")
true

julia> contains("JuliaLang is pretty cool!", 'a')
true

julia> contains("aba", r"a.a")
true

julia> contains("abba", r"a.a")
false
```
The `contains` function requires at least Julia 1.5.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L114-L140)
```julia
contains(needle)
```
Create a function that checks whether its argument contains `needle`, i.e. a function equivalent to `haystack -> contains(haystack, needle)`.
The returned function is of type `Base.Fix2{typeof(contains)}`, which can be used to implement specialized methods.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L189-L197)
```julia
first(s::AbstractString, n::Integer)
```
Get a string consisting of the first `n` characters of `s`.
**Examples**
```julia-repl
julia> first("∀ϵ≠0: ϵ²>0", 0)
""

julia> first("∀ϵ≠0: ϵ²>0", 1)
"∀"

julia> first("∀ϵ≠0: ϵ²>0", 3)
"∀ϵ≠"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L690-L706)
```julia
last(s::AbstractString, n::Integer)
```
Get a string consisting of the last `n` characters of `s`.
**Examples**
```julia-repl
julia> last("∀ϵ≠0: ϵ²>0", 0)
""

julia> last("∀ϵ≠0: ϵ²>0", 1)
"0"

julia> last("∀ϵ≠0: ϵ²>0", 3)
"²>0"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L709-L725)
```julia
uppercase(c::AbstractChar)
```


# [Strings](#lib-strings)
Convert `c` to uppercase.
See also [`lowercase`](#Base.Unicode.lowercase), [`titlecase`](#Base.Unicode.titlecase).
**Examples**
```julia-repl
julia> uppercase('a')
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)

julia> uppercase('ê')
'Ê': Unicode U+00CA (category Lu: Letter, uppercase)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L299-L314)
```julia
uppercase(s::AbstractString)
```
Return `s` with all characters converted to uppercase.
See also [`lowercase`](#Base.Unicode.lowercase), [`titlecase`](#Base.Unicode.titlecase), [`uppercasefirst`](#Base.Unicode.uppercasefirst).
**Examples**
```julia-repl
julia> uppercase("Julia")
"JULIA"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L605-L617)
```julia
lowercase(c::AbstractChar)
```
Convert `c` to lowercase.
See also [`uppercase`](#Base.Unicode.uppercase), [`titlecase`](#Base.Unicode.titlecase).
**Examples**
```julia-repl
julia> lowercase('A')
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)

julia> lowercase('Ö')
'ö': Unicode U+00F6 (category Ll: Letter, lowercase)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L278-L293)
```julia
lowercase(s::AbstractString)
```
Return `s` with all characters converted to lowercase.
See also [`uppercase`](#Base.Unicode.uppercase), [`titlecase`](#Base.Unicode.titlecase), [`lowercasefirst`](#Base.Unicode.lowercasefirst).
**Examples**


# [Strings](#lib-strings)
```julia-repl
julia> lowercase("STRINGS AND THINGS")
"strings and things"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L621-L633)
```julia
titlecase(c::AbstractChar)
```
Convert `c` to titlecase. This may differ from uppercase for digraphs, compare the example below.
See also [`uppercase`](#Base.Unicode.uppercase), [`lowercase`](#Base.Unicode.lowercase).
**Examples**
```julia-repl
julia> titlecase('a')
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)

julia> titlecase('ǆ')
'ǅ': Unicode U+01C5 (category Lt: Letter, titlecase)

julia> uppercase('ǆ')
'Ǆ': Unicode U+01C4 (category Lu: Letter, uppercase)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L320-L339)
```julia
titlecase(s::AbstractString; [wordsep::Function], strict::Bool=true) -> String
```
Capitalize the first character of each word in `s`; if `strict` is true, every other character is converted to lowercase, otherwise they are left unchanged. By default, all non-letters beginning a new grapheme are considered as word separators; a predicate can be passed as the `wordsep` keyword to determine which characters should be considered as word separators. See also [`uppercasefirst`](#Base.Unicode.uppercasefirst) to capitalize only the first character in `s`.
See also [`uppercase`](#Base.Unicode.uppercase), [`lowercase`](#Base.Unicode.lowercase), [`uppercasefirst`](#Base.Unicode.uppercasefirst).
**Examples**


# [Strings](#lib-strings)
```julia-repl
julia> titlecase("the JULIA programming language")
"The Julia Programming Language"

julia> titlecase("ISS - international space station", strict=false)
"ISS - International Space Station"

julia> titlecase("a-a b-b", wordsep = c->c==' ')
"A-a B-b"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L637-L662)
```julia
uppercasefirst(s::AbstractString) -> String
```
Return `s` with the first character converted to uppercase (technically "title case" for Unicode). See also [`titlecase`](#Base.Unicode.titlecase) to capitalize the first character of every word in `s`.
See also [`lowercasefirst`](#Base.Unicode.lowercasefirst), [`uppercase`](#Base.Unicode.uppercase), [`lowercase`](#Base.Unicode.lowercase), [`titlecase`](#Base.Unicode.titlecase).
**Examples**
```julia-repl
julia> uppercasefirst("python")
"Python"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L701-L716)
```julia
lowercasefirst(s::AbstractString)
```
Return `s` with the first character converted to lowercase.
See also [`uppercasefirst`](#Base.Unicode.uppercasefirst), [`uppercase`](#Base.Unicode.uppercase), [`lowercase`](#Base.Unicode.lowercase), [`titlecase`](#Base.Unicode.titlecase).
**Examples**
```julia-repl
julia> lowercasefirst("Julia")
"julia"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L736-L749)
```julia
join([io::IO,] iterator [, delim [, last]])
```


# [Strings](#lib-strings)
Join any `iterator` into a single string, inserting the given delimiter (if any) between adjacent items. If `last` is given, it will be used instead of `delim` between the last two items. Each item of `iterator` is converted to a string via `print(io::IOBuffer, x)`. If `io` is given, the result is written to `io` rather than returned as a `String`.
**Examples**
```julia-repl
julia> join(["apples", "bananas", "pineapples"], ", ", " and ")
"apples, bananas and pineapples"

julia> join([1,2,3,4,5])
"12345"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/io.jl#L313-L329)
```julia
chop(s::AbstractString; head::Integer = 0, tail::Integer = 1)
```
Remove the first `head` and the last `tail` characters from `s`. The call `chop(s)` removes the last character from `s`. If it is requested to remove more characters than `length(s)` then an empty string is returned.
See also [`chomp`](#Base.chomp), [`startswith`](#Base.startswith), [`first`](../collections/#Base.first).
**Examples**
```julia-repl
julia> a = "March"
"March"

julia> chop(a)
"Marc"

julia> chop(a, head = 1, tail = 2)
"ar"

julia> chop(a, head = 5, tail = 5)
""
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L200-L224)
```julia
chopprefix(s::AbstractString, prefix::Union{AbstractString,Regex}) -> SubString
```
Remove the prefix `prefix` from `s`. If `s` does not start with `prefix`, a string equal to `s` is returned.
See also [`chopsuffix`](#Base.chopsuffix).


# [Strings](#lib-strings)
This function is available as of Julia 1.8.
**Examples**
```julia-repl
julia> chopprefix("Hamburger", "Ham")
"burger"

julia> chopprefix("Hamburger", "hotdog")
"Hamburger"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L235-L253)
```julia
chopsuffix(s::AbstractString, suffix::Union{AbstractString,Regex}) -> SubString
```
Remove the suffix `suffix` from `s`. If `s` does not end with `suffix`, a string equal to `s` is returned.
See also [`chopprefix`](#Base.chopprefix).
This function is available as of Julia 1.8.
**Examples**
```julia-repl
julia> chopsuffix("Hamburger", "er")
"Hamburg"

julia> chopsuffix("Hamburger", "hotdog")
"Hamburger"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L276-L294)
```julia
chomp(s::AbstractString) -> SubString
```
Remove a single trailing newline from a string.
See also [`chop`](#Base.chop).
**Examples**
```julia-repl
julia> chomp("Hello\n")
"Hello"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/util.jl#L320-L332)
```julia
thisind(s::AbstractString, i::Integer) -> Int
```


# [Strings](#lib-strings)
If `i` is in bounds in `s` return the index of the start of the character whose encoding code unit `i` is part of. In other words, if `i` is the start of a character, return `i`; if `i` is not the start of a character, rewind until the start of a character and return that index. If `i` is equal to 0 or `ncodeunits(s)+1` return `i`. In all other cases throw `BoundsError`.
**Examples**
```julia-repl
julia> thisind("α", 0)
0

julia> thisind("α", 1)
1

julia> thisind("α", 2)
1

julia> thisind("α", 3)
3

julia> thisind("α", 4)
ERROR: BoundsError: attempt to access 2-codeunit String at index [4]
[...]

julia> thisind("α", -1)
ERROR: BoundsError: attempt to access 2-codeunit String at index [-1]
[...]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L421-L452)
```julia
nextind(str::AbstractString, i::Integer, n::Integer=1) -> Int
```
-   Case `n == 1`
    If `i` is in bounds in `s` return the index of the start of the character whose encoding starts after index `i`. In other words, if `i` is the start of a character, return the start of the next character; if `i` is not the start of a character, move forward until the start of a character and return that index. If `i` is equal to `0` return `1`. If `i` is in bounds but greater or equal to `lastindex(str)` return `ncodeunits(str)+1`. Otherwise throw `BoundsError`.
-   Case `n > 1`


# [Strings](#lib-strings)
    Behaves like applying `n` times `nextind` for `n==1`. The only difference is that if `n` is so large that applying `nextind` would reach `ncodeunits(str)+1` then each remaining iteration increases the returned value by `1`. This means that in this case `nextind` can return a value greater than `ncodeunits(str)+1`.
-   Case `n == 0`
    Return `i` only if `i` is a valid index in `s` or is equal to `0`. Otherwise `StringIndexError` or `BoundsError` is thrown.
**Examples**
```julia-repl
julia> nextind("α", 0)
1

julia> nextind("α", 1)
3

julia> nextind("α", 3)
ERROR: BoundsError: attempt to access 2-codeunit String at index [3]
[...]

julia> nextind("α", 0, 2)
3

julia> nextind("α", 1, 2)
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L524-L567)
```julia
prevind(str::AbstractString, i::Integer, n::Integer=1) -> Int
```
-   Case `n == 1`
    If `i` is in bounds in `s` return the index of the start of the character whose encoding starts before index `i`. In other words, if `i` is the start of a character, return the start of the previous character; if `i` is not the start of a character, rewind until the start of a character and return that index. If `i` is equal to `1` return `0`. If `i` is equal to `ncodeunits(str)+1` return `lastindex(str)`. Otherwise throw `BoundsError`.
-   Case `n > 1`


# [Strings](#lib-strings)
    Behaves like applying `n` times `prevind` for `n==1`. The only difference is that if `n` is so large that applying `prevind` would reach `0` then each remaining iteration decreases the returned value by `1`. This means that in this case `prevind` can return a negative value.
-   Case `n == 0`
    Return `i` only if `i` is a valid index in `str` or is equal to `ncodeunits(str)+1`. Otherwise `StringIndexError` or `BoundsError` is thrown.
**Examples**
```julia-repl
julia> prevind("α", 3)
1

julia> prevind("α", 1)
0

julia> prevind("α", 0)
ERROR: BoundsError: attempt to access 2-codeunit String at index [0]
[...]

julia> prevind("α", 2, 2)
0

julia> prevind("α", 2, 3)
-1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L465-L508)
```julia
textwidth(c)
```
Give the number of columns needed to print a character.
**Examples**
```julia-repl
julia> textwidth('α')
1

julia> textwidth('⛵')
2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L244-L257)
```julia
textwidth(s::AbstractString)
```
Give the number of columns needed to print a string.
**Examples**
```julia-repl
julia> textwidth("March")
5
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L263-L273)
```julia
isascii(c::Union{AbstractChar,AbstractString}) -> Bool
```
Test whether a character belongs to the ASCII character set, or whether this is true for all elements of a string.
**Examples**


# [Strings](#lib-strings)
```julia-repl
julia> isascii('a')
true

julia> isascii('α')
false

julia> isascii("abc")
true

julia> isascii("αβγ")
false
```
For example, `isascii` can be used as a predicate function for [`filter`](../collections/#Base.filter) or [`replace`](../collections/#Base.replace-Tuple%7BAny,%20Vararg%7BPair%7D%7D) to remove or replace non-ASCII characters, respectively:
```julia-repl
julia> filter(isascii, "abcdeγfgh") # discard non-ASCII chars
"abcdefgh"

julia> replace("abcdeγfgh", !isascii=>' ') # replace non-ASCII chars with spaces
"abcde fgh"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L596-L625)
```julia
isascii(cu::AbstractVector{CU}) where {CU <: Integer} -> Bool
```
Test whether all values in the vector belong to the ASCII character set (0x00 to 0x7f). This function is intended to be used by other string implementations that need a fast ASCII check.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L647-L652)
```julia
iscntrl(c::AbstractChar) -> Bool
```
Tests whether a character is a control character. Control characters are the non-printing characters of the Latin-1 subset of Unicode.
**Examples**
```julia-repl
julia> iscntrl('\x01')
true

julia> iscntrl('a')
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L503-L517)
```julia
isdigit(c::AbstractChar) -> Bool
```
Tests whether a character is a decimal digit (0-9).


# [Strings](#lib-strings)
See also: [`isletter`](#Base.Unicode.isletter).
**Examples**
```julia-repl
julia> isdigit('❤')
false

julia> isdigit('9')
true

julia> isdigit('α')
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L430-L448)
```julia
isletter(c::AbstractChar) -> Bool
```
Test whether a character is a letter. A character is classified as a letter if it belongs to the Unicode general category Letter, i.e. a character whose category code begins with 'L'.
See also: [`isdigit`](#Base.Unicode.isdigit).
**Examples**
```julia-repl
julia> isletter('❤')
false

julia> isletter('α')
true

julia> isletter('9')
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L451-L471)
```julia
islowercase(c::AbstractChar) -> Bool
```
Tests whether a character is a lowercase letter (according to the Unicode standard's `Lowercase` derived property).
See also [`isuppercase`](#Base.Unicode.isuppercase).
**Examples**
```julia-repl
julia> islowercase('α')
true

julia> islowercase('Γ')
false

julia> islowercase('❤')
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L369-L388)
```julia
isnumeric(c::AbstractChar) -> Bool
```
Tests whether a character is numeric. A character is classified as numeric if it belongs to the Unicode general category Number, i.e. a character whose category code begins with 'N'.


# [Strings](#lib-strings)
Note that this broad category includes characters such as ¾ and ௰. Use [`isdigit`](#Base.Unicode.isdigit) to check whether a character is a decimal digit between 0 and 9.
**Examples**
```julia-repl
julia> isnumeric('௰')
true

julia> isnumeric('9')
true

julia> isnumeric('α')
false

julia> isnumeric('❤')
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L474-L498)
```julia
isprint(c::AbstractChar) -> Bool
```
Tests whether a character is printable, including spaces, but not a control character.
**Examples**
```julia-repl
julia> isprint('\x01')
false

julia> isprint('A')
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L568-L581)
```julia
ispunct(c::AbstractChar) -> Bool
```
Tests whether a character belongs to the Unicode general category Punctuation, i.e. a character whose category code begins with 'P'.
**Examples**
```julia-repl
julia> ispunct('α')
false

julia> ispunct('/')
true

julia> ispunct(';')
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L520-L537)
```julia
isspace(c::AbstractChar) -> Bool
```
Tests whether a character is any whitespace character. Includes ASCII characters '\\t', '\\n', '\\v', '\\f', '\\r', and ' ', Latin-1 character U+0085, and characters in Unicode category Zs.
**Examples**
```julia-repl
julia> isspace('\n')
true

julia> isspace('\r')
true

julia> isspace(' ')
true

julia> isspace('\x20')
true
```


# [Strings](#lib-strings)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L542-L563)
```julia
isuppercase(c::AbstractChar) -> Bool
```
Tests whether a character is an uppercase letter (according to the Unicode standard's `Uppercase` derived property).
See also [`islowercase`](#Base.Unicode.islowercase).
**Examples**
```julia-repl
julia> isuppercase('γ')
false

julia> isuppercase('Γ')
true

julia> isuppercase('❤')
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L393-L412)
```julia
isxdigit(c::AbstractChar) -> Bool
```
Test whether a character is a valid hexadecimal digit. Note that this does not include `x` (as in the standard `0x` prefix).
**Examples**
```julia-repl
julia> isxdigit('a')
true

julia> isxdigit('x')
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/unicode.jl#L586-L600)
```julia
escape_string(str::AbstractString[, esc]; keep = ())::AbstractString
escape_string(io, str::AbstractString[, esc]; keep = ())::Nothing
```
General escaping of traditional C and Unicode escape sequences. The first form returns the escaped string, the second prints the result to `io`.
Backslashes (`\`) are escaped with a double-backslash (`"\\"`). Non-printable characters are escaped either with their standard C escape codes, `"\0"` for NUL (if unambiguous), unicode code point (`"\u"` prefix) or hex (`"\x"` prefix).


# [Strings](#lib-strings)
The optional `esc` argument specifies any additional characters that should also be escaped by a prepending backslash (`"` is also escaped by default in the first form).
The argument `keep` specifies a collection of characters which are to be kept as they are. Notice that `esc` has precedence here.
See also [`unescape_string`](#Base.unescape_string) for the reverse operation.
The `keep` argument is available as of Julia 1.7.
**Examples**
```julia-repl
julia> escape_string("aaa\nbbb")
"aaa\\nbbb"

julia> escape_string("aaa\nbbb"; keep = '\n')
"aaa\nbbb"

julia> escape_string("\xfe\xff") # invalid utf-8
"\\xfe\\xff"

julia> escape_string(string('\u2135','\0')) # unambiguous
"ℵ\\0"

julia> escape_string(string('\u2135','\0','0')) # \0 would be ambiguous
"ℵ\\x000"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/io.jl#L386-L425)
```julia
escape_raw_string(s::AbstractString, delim='"') -> AbstractString
escape_raw_string(io, s::AbstractString, delim='"')
```
Escape a string in the manner used for parsing raw string literals. For each double-quote (`"`) character in input string `s` (or `delim` if specified), this function counts the number *n* of preceding backslash (`\`) characters, and then increases there the number of backslashes from *n* to 2*n*+1 (even for *n* = 0). It also doubles a sequence of backslashes at the end of the string.


# [Strings](#lib-strings)
This escaping convention is used in raw strings and other non-standard string literals. (It also happens to be the escaping convention expected by the Microsoft C/C++ compiler runtime when it parses a command-line string into the argv\[\] array.)
See also [`escape_string`](#Base.escape_string).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/io.jl#L612-L629)
```julia
unescape_string(str::AbstractString, keep = ())::AbstractString
unescape_string(io, s::AbstractString, keep = ())::Nothing
```
General unescaping of traditional C and Unicode escape sequences. The first form returns the escaped string, the second prints the result to `io`. The argument `keep` specifies a collection of characters which (along with backlashes) are to be kept as they are.
The following escape sequences are recognised:
-   Escaped backslash (`\\`)
-   Escaped double-quote (`\"`)
-   Standard C escape sequences (`\a`, `\b`, `\t`, `\n`, `\v`, `\f`, `\r`, `\e`)
-   Unicode BMP code points (`\u` with 1-4 trailing hex digits)
-   All Unicode code points (`\U` with 1-8 trailing hex digits; max value = 0010ffff)
-   Hex bytes (`\x` with 1-2 trailing hex digits)
-   Octal bytes (`\` with 1-3 trailing octal digits)
See also [`escape_string`](#Base.escape_string).
**Examples**


# [Strings](#lib-strings)
```julia-repl
julia> unescape_string("aaa\\nbbb") # C escape sequence
"aaa\nbbb"

julia> unescape_string("\\u03c0") # unicode
"π"

julia> unescape_string("\\101") # octal
"A"

julia> unescape_string("aaa \\g \\n", ['g']) # using `keep` argument
"aaa \\g \n"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/io.jl#L467-L501)


## [AnnotatedStrings](#AnnotatedStrings)
The API for AnnotatedStrings is considered experimental and is subject to change between Julia versions.
```julia
AnnotatedString{S <: AbstractString} <: AbstractString
```
A string with metadata, in the form of annotated regions.
More specifically, this is a simple wrapper around any other [`AbstractString`](#Core.AbstractString) that allows for regions of the wrapped string to be annotated with labeled values.
```text
                           C
                    ┌──────┸─────────┐
  "this is an example annotated string"
  └──┰────────┼─────┘         │
     A        └─────┰─────────┘
                    B
```
The above diagram represents a `AnnotatedString` where three ranges have been annotated (labeled `A`, `B`, and `C`). Each annotation holds a label (`Symbol`) and a value (`Any`). These three pieces of information are held as a `@NamedTuple{region::UnitRange{Int64}, label::Symbol, value}`.
Labels do not need to be unique, the same region can hold multiple annotations with the same label.
Code written for `AnnotatedString`s in general should conserve the following properties:
-   Which characters an annotation is applied to
-   The order in which annotations are applied to each character
Additional semantics may be introduced by specific uses of `AnnotatedString`s.
A corollary of these rules is that adjacent, consecutively placed, annotations with identical labels and values are equivalent to a single annotation spanning the combined range.


## [AnnotatedStrings](#AnnotatedStrings)
See also [`AnnotatedChar`](#Base.AnnotatedChar), [`annotatedstring`](#Base.annotatedstring), [`annotations`](#Base.annotations), and [`annotate!`](#Base.annotate!).
**Constructors**
```julia
AnnotatedString(s::S<:AbstractString) -> AnnotatedString{S}
AnnotatedString(s::S<:AbstractString, annotations::Vector{@NamedTuple{region::UnitRange{Int64}, label::Symbol, value}})
```
A AnnotatedString can also be created with [`annotatedstring`](#Base.annotatedstring), which acts much like [`string`](#Base.string) but preserves any annotations present in the arguments.
**Examples**
```julia-repl
julia> AnnotatedString("this is an example annotated string",
                    [(1:18, :A => 1), (12:28, :B => 2), (18:35, :C => 3)])
"this is an example annotated string"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/annotated.jl#L6-L63)
```julia
AnnotatedChar{S <: AbstractChar} <: AbstractChar
```
A Char with annotations.
More specifically, this is a simple wrapper around any other [`AbstractChar`](#Core.AbstractChar), which holds a list of arbitrary labelled annotations (`@NamedTuple{label::Symbol, value}`) with the wrapped character.
See also: [`AnnotatedString`](#Base.AnnotatedString), [`annotatedstring`](#Base.annotatedstring), `annotations`, and `annotate!`.
**Constructors**
```julia
AnnotatedChar(s::S) -> AnnotatedChar{S}
AnnotatedChar(s::S, annotations::Vector{@NamedTuple{label::Symbol, value}})
```
**Examples**


## [AnnotatedStrings](#AnnotatedStrings)
```julia-repl
julia> AnnotatedChar('j', :label => 1)
'j': ASCII/Unicode U+006A (category Ll: Letter, lowercase)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/annotated.jl#L69-L94)
```julia
annotatedstring(values...)
```
Create a `AnnotatedString` from any number of `values` using their [`print`](../io-network/#Base.print)ed representation.
This acts like [`string`](#Base.string), but takes care to preserve any annotations present (in the form of [`AnnotatedString`](#Base.AnnotatedString) or [`AnnotatedChar`](#Base.AnnotatedChar) values).
See also [`AnnotatedString`](#Base.AnnotatedString) and [`AnnotatedChar`](#Base.AnnotatedChar).
**Examples**
```julia-repl
julia> annotatedstring("now a AnnotatedString")
"now a AnnotatedString"

julia> annotatedstring(AnnotatedString("annotated", [(1:9, :label => 1)]), ", and unannotated")
"annotated, and unannotated"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/annotated.jl#L222-L242)
```julia
annotations(str::Union{AnnotatedString, SubString{AnnotatedString}},
            [position::Union{Integer, UnitRange}]) ->
    Vector{@NamedTuple{region::UnitRange{Int64}, label::Symbol, value}}
```
Get all annotations that apply to `str`. Should `position` be provided, only annotations that overlap with `position` will be returned.
Annotations are provided together with the regions they apply to, in the form of a vector of region–annotation tuples.


## [AnnotatedStrings](#AnnotatedStrings)
In accordance with the semantics documented in [`AnnotatedString`](#Base.AnnotatedString), the order of annotations returned matches the order in which they were applied.
See also: [`annotate!`](#Base.annotate!).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/annotated.jl#L373-L388)
```julia
annotations(chr::AnnotatedChar) -> Vector{@NamedTuple{label::Symbol, value}}
```
Get all annotations of `chr`, in the form of a vector of annotation pairs.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/annotated.jl#L412-L416)
```julia
annotate!(str::AnnotatedString, [range::UnitRange{Int}], label::Symbol, value)
annotate!(str::SubString{AnnotatedString}, [range::UnitRange{Int}], label::Symbol, value)
```
Annotate a `range` of `str` (or the entire string) with a labeled value (`label` => `value`). To remove existing `label` annotations, use a value of `nothing`.
The order in which annotations are applied to `str` is semantically meaningful, as described in [`AnnotatedString`](#Base.AnnotatedString).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/annotated.jl#L343-L352)
```julia
annotate!(char::AnnotatedChar, label::Symbol, value::Any)
```
Annotate `char` with the pair `label => value`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/annotated.jl#L365-L369)


## [AnnotatedStrings](#AnnotatedStrings)
------------------------------------------------------------------------


# Arrays · The Julia Language
Source: https://docs.julialang.org/en/v1/base/arrays/


# [Arrays](#lib-arrays)


## [Constructors and Types](#Constructors-and-Types)
```julia
AbstractArray{T,N}
```
Supertype for `N`-dimensional arrays (or array-like types) with elements of type `T`. [`Array`](#Core.Array) and other types are subtypes of this. See the manual section on the [`AbstractArray` interface](../../manual/interfaces/#man-interface-array).
See also: [`AbstractVector`](#Base.AbstractVector), [`AbstractMatrix`](#Base.AbstractMatrix), [`eltype`](../collections/#Base.eltype), [`ndims`](#Base.ndims).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L5-L13)
```julia
AbstractVector{T}
```
Supertype for one-dimensional arrays (or array-like types) with elements of type `T`. Alias for [`AbstractArray{T,1}`](#Core.AbstractArray).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L17-L22)
```julia
AbstractMatrix{T}
```
Supertype for two-dimensional arrays (or array-like types) with elements of type `T`. Alias for [`AbstractArray{T,2}`](#Core.AbstractArray).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L25-L30)
```julia
AbstractVecOrMat{T}
```
Union type of [`AbstractVector{T}`](#Base.AbstractVector) and [`AbstractMatrix{T}`](#Base.AbstractMatrix).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L33-L37)
```julia
Array{T,N} <: AbstractArray{T,N}
```
`N`-dimensional dense array with elements of type `T`.


## [Constructors and Types](#Constructors-and-Types)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L45-L49)
```julia
Array{T}(undef, dims)
Array{T,N}(undef, dims)
```
Construct an uninitialized `N`-dimensional [`Array`](#Core.Array) containing elements of type `T`. `N` can either be supplied explicitly, as in `Array{T,N}(undef, dims)`, or be determined by the length or number of `dims`. `dims` may be a tuple or a series of integer arguments corresponding to the lengths in each dimension. If the rank `N` is supplied explicitly, then it must match the length or number of `dims`. Here [`undef`](#Core.undef) is the [`UndefInitializer`](#Core.UndefInitializer).
**Examples**
```julia-repl
julia> A = Array{Float64, 2}(undef, 2, 3) # N given explicitly
2×3 Matrix{Float64}:
 6.90198e-310  6.90198e-310  6.90198e-310
 6.90198e-310  6.90198e-310  0.0

julia> B = Array{Float64}(undef, 4) # N determined by the input
4-element Vector{Float64}:
   2.360075077e-314
 NaN
   2.2671131793e-314
   2.299821756e-314

julia> similar(B, 2, 4, 1) # use typeof(B), and the given size
2×4×1 Array{Float64, 3}:
[:, :, 1] =
 2.26703e-314  2.26708e-314  0.0           2.80997e-314
 0.0           2.26703e-314  2.26708e-314  0.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2821-L2853)
```julia
Array{T}(nothing, dims)
Array{T,N}(nothing, dims)
```


## [Constructors and Types](#Constructors-and-Types)
Construct an `N`-dimensional [`Array`](#Core.Array) containing elements of type `T`, initialized with [`nothing`](../constants/#Core.nothing) entries. Element type `T` must be able to hold these values, i.e. `Nothing <: T`.
**Examples**
```julia-repl
julia> Array{Union{Nothing, String}}(nothing, 2)
2-element Vector{Union{Nothing, String}}:
 nothing
 nothing

julia> Array{Union{Nothing, Int}}(nothing, 2, 3)
2×3 Matrix{Union{Nothing, Int64}}:
 nothing  nothing  nothing
 nothing  nothing  nothing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2856-L2876)
```julia
Array{T}(missing, dims)
Array{T,N}(missing, dims)
```
Construct an `N`-dimensional [`Array`](#Core.Array) containing elements of type `T`, initialized with [`missing`](../../manual/missing/#missing) entries. Element type `T` must be able to hold these values, i.e. `Missing <: T`.
**Examples**
```julia-repl
julia> Array{Union{Missing, String}}(missing, 2)
2-element Vector{Union{Missing, String}}:
 missing
 missing

julia> Array{Union{Missing, Int}}(missing, 2, 3)
2×3 Matrix{Union{Missing, Int64}}:
 missing  missing  missing
 missing  missing  missing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2880-L2900)
```julia
UndefInitializer
```
Singleton type used in array initialization, indicating the array-constructor-caller would like an uninitialized array. See also [`undef`](#Core.undef), an alias for `UndefInitializer()`.


## [Constructors and Types](#Constructors-and-Types)
**Examples**
```julia-repl
julia> Array{Float64, 1}(UndefInitializer(), 3)
3-element Array{Float64, 1}:
 2.2752528595e-314
 2.202942107e-314
 2.275252907e-314
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2903-L2918)
```julia
undef
```
Alias for `UndefInitializer()`, which constructs an instance of the singleton type [`UndefInitializer`](#Core.UndefInitializer), used in array initialization to indicate the array-constructor-caller would like an uninitialized array.
See also: [`missing`](../../manual/missing/#missing), [`similar`](#Base.similar).
**Examples**
```julia-repl
julia> Array{Float64, 1}(undef, 3)
3-element Vector{Float64}:
 2.2752528595e-314
 2.202942107e-314
 2.275252907e-314
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2921-L2938)
```julia
Vector{T} <: AbstractVector{T}
```
One-dimensional dense array with elements of type `T`, often used to represent a mathematical vector. Alias for [`Array{T,1}`](#Core.Array).
See also [`empty`](#Base.empty), [`similar`](#Base.similar) and [`zero`](../numbers/#Base.zero) for creating vectors.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L52-L59)
```julia
Vector{T}(undef, n)
```
Construct an uninitialized [`Vector{T}`](#Base.Vector) of length `n`.
**Examples**


## [Constructors and Types](#Constructors-and-Types)
```julia-repl
julia> Vector{Float64}(undef, 3)
3-element Array{Float64, 1}:
 6.90966e-310
 6.90966e-310
 6.90966e-310
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2717-L2730)
```julia
Vector{T}(nothing, m)
```
Construct a [`Vector{T}`](#Base.Vector) of length `m`, initialized with [`nothing`](../constants/#Core.nothing) entries. Element type `T` must be able to hold these values, i.e. `Nothing <: T`.
**Examples**
```julia-repl
julia> Vector{Union{Nothing, String}}(nothing, 2)
2-element Vector{Union{Nothing, String}}:
 nothing
 nothing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2733-L2747)
```julia
Vector{T}(missing, m)
```
Construct a [`Vector{T}`](#Base.Vector) of length `m`, initialized with [`missing`](../../manual/missing/#missing) entries. Element type `T` must be able to hold these values, i.e. `Missing <: T`.
**Examples**
```julia-repl
julia> Vector{Union{Missing, String}}(missing, 2)
2-element Vector{Union{Missing, String}}:
 missing
 missing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2750-L2764)
```julia
Matrix{T} <: AbstractMatrix{T}
```
Two-dimensional dense array with elements of type `T`, often used to represent a mathematical matrix. Alias for [`Array{T,2}`](#Core.Array).


## [Constructors and Types](#Constructors-and-Types)
See also [`fill`](#Base.fill), [`zeros`](#Base.zeros), [`undef`](#Core.undef) and [`similar`](#Base.similar) for creating matrices.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L62-L70)
```julia
Matrix{T}(undef, m, n)
```
Construct an uninitialized [`Matrix{T}`](#Base.Matrix) of size `m`×`n`.
**Examples**
```julia-repl
julia> Matrix{Float64}(undef, 2, 3)
2×3 Array{Float64, 2}:
 2.36365e-314  2.28473e-314    5.0e-324
 2.26704e-314  2.26711e-314  NaN

julia> similar(ans, Int32, 2, 2)
2×2 Matrix{Int32}:
 490537216  1277177453
         1  1936748399
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2767-L2784)
```julia
Matrix{T}(nothing, m, n)
```
Construct a [`Matrix{T}`](#Base.Matrix) of size `m`×`n`, initialized with [`nothing`](../constants/#Core.nothing) entries. Element type `T` must be able to hold these values, i.e. `Nothing <: T`.
**Examples**
```julia-repl
julia> Matrix{Union{Nothing, String}}(nothing, 2, 3)
2×3 Matrix{Union{Nothing, String}}:
 nothing  nothing  nothing
 nothing  nothing  nothing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2787-L2801)
```julia
Matrix{T}(missing, m, n)
```
Construct a [`Matrix{T}`](#Base.Matrix) of size `m`×`n`, initialized with [`missing`](../../manual/missing/#missing) entries. Element type `T` must be able to hold these values, i.e. `Missing <: T`.
**Examples**


## [Constructors and Types](#Constructors-and-Types)
```julia-repl
julia> Matrix{Union{Missing, String}}(missing, 2, 3)
2×3 Matrix{Union{Missing, String}}:
 missing  missing  missing
 missing  missing  missing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2804-L2818)
```julia
VecOrMat{T}
```
Union type of [`Vector{T}`](#Base.Vector) and [`Matrix{T}`](#Base.Matrix) which allows functions to accept either a Matrix or a Vector.
**Examples**
```julia-repl
julia> Vector{Float64} <: VecOrMat{Float64}
true

julia> Matrix{Float64} <: VecOrMat{Float64}
true

julia> Array{Float64, 3} <: VecOrMat{Float64}
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L73-L89)
```julia
DenseArray{T, N} <: AbstractArray{T,N}
```
`N`-dimensional dense array with elements of type `T`. The elements of a dense array are stored contiguously in memory.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L92-L97)
```julia
DenseVector{T}
```
One-dimensional [`DenseArray`](#Core.DenseArray) with elements of type `T`. Alias for `DenseArray{T,1}`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L100-L104)
```julia
DenseMatrix{T}
```
Two-dimensional [`DenseArray`](#Core.DenseArray) with elements of type `T`. Alias for `DenseArray{T,2}`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L107-L111)


## [Constructors and Types](#Constructors-and-Types)
```julia
DenseVecOrMat{T}
```
Union type of [`DenseVector{T}`](#Base.DenseVector) and [`DenseMatrix{T}`](#Base.DenseMatrix).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L114-L118)
```julia
StridedArray{T, N}
```
A hard-coded [`Union`](../base/#Core.Union) of common array types that follow the [strided array interface](../../manual/interfaces/#man-interface-strided-arrays), with elements of type `T` and `N` dimensions.
If `A` is a `StridedArray`, then its elements are stored in memory with offsets, which may vary between dimensions but are constant within a dimension. For example, `A` could have stride 2 in dimension 1, and stride 3 in dimension 2. Incrementing `A` along dimension `d` jumps in memory by \[`stride(A, d)`\] slots. Strided arrays are particularly important and useful because they can sometimes be passed directly as pointers to foreign language libraries like BLAS.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L3489-L3501)
```julia
StridedVector{T}
```
One dimensional [`StridedArray`](#Base.StridedArray) with elements of type `T`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L3504-L3508)
```julia
StridedMatrix{T}
```
Two dimensional [`StridedArray`](#Base.StridedArray) with elements of type `T`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L3511-L3515)


## [Constructors and Types](#Constructors-and-Types)
```julia
StridedVecOrMat{T}
```
Union type of [`StridedVector`](#Base.StridedVector) and [`StridedMatrix`](#Base.StridedMatrix) with elements of type `T`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L3518-L3522)
```julia
GenericMemory{kind::Symbol, T, addrspace=Core.CPU} <: DenseVector{T}
```
Fixed-size [`DenseVector{T}`](#Base.DenseVector).
`kind` can currently be either `:not_atomic` or `:atomic`. For details on what `:atomic` implies, see [`AtomicMemory`](../multi-threading/#Core.AtomicMemory)
`addrspace` can currently only be set to Core.CPU. It is designed to to permit extension by other systems such as GPUs, which might define values such as:
```julia
module CUDA
const Generic = bitcast(Core.AddrSpace{CUDA}, 0)
const Global = bitcast(Core.AddrSpace{CUDA}, 1)
end
```
The exact semantics of these other addrspaces is defined by the specific backend, but will error if the user is attempting to access these on the CPU.
This type requires Julia 1.11 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/genericmemory.jl#L5-L24)
```julia
Memory{T} == GenericMemory{:not_atomic, T, Core.CPU}
```
Fixed-size [`DenseVector{T}`](#Base.DenseVector).
This type requires Julia 1.11 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/genericmemory.jl#L27-L34)
```julia
`memoryref(::GenericMemory)`
```


## [Constructors and Types](#Constructors-and-Types)
Construct a `GenericMemoryRef` from a memory object. This does not fail, but the resulting memory will point out-of-bounds if and only if the memory is empty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2698-L2703)
```julia
memoryref(::GenericMemory, index::Integer)
memoryref(::GenericMemoryRef, index::Integer)
```
Construct a `GenericMemoryRef` from a memory object and an offset index (1-based) which can also be negative. This always returns an inbounds object, and will throw an error if that is not possible (because the index would result in a shift out-of-bounds of the underlying memory).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2706-L2714)
```julia
Slices{P,SM,AX,S,N} <: AbstractSlices{S,N}
```
An `AbstractArray` of slices into a parent array over specified dimension(s), returning views that select all the data from the other dimension(s).
These should typically be constructed by [`eachslice`](#Base.eachslice), [`eachcol`](#Base.eachcol) or [`eachrow`](#Base.eachrow).
[`parent(s::Slices)`](#Base.parent) will return the parent array.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/slicearray.jl#L11-L21)
```julia
RowSlices{M,AX,S}
```
A special case of [`Slices`](#Base.Slices) that is a vector of row slices of a matrix, as constructed by [`eachrow`](#Base.eachrow).
[`parent`](#Base.parent) can be used to get the underlying matrix.


## [Constructors and Types](#Constructors-and-Types)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/slicearray.jl#L207-L214)
```julia
ColumnSlices{M,AX,S}
```
A special case of [`Slices`](#Base.Slices) that is a vector of column slices of a matrix, as constructed by [`eachcol`](#Base.eachcol).
[`parent`](#Base.parent) can be used to get the underlying matrix.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/slicearray.jl#L217-L224)
```julia
getindex(type[, elements...])
```
Construct a 1-d array of the specified type. This is usually called with the syntax `Type[]`. Element values can be specified using `Type[a,b,c,...]`.
**Examples**
```julia-repl
julia> Int8[1, 2, 3]
3-element Vector{Int8}:
 1
 2
 3

julia> getindex(Int8, 1, 2, 3)
3-element Vector{Int8}:
 1
 2
 3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L376-L396)
```julia
zeros([T=Float64,] dims::Tuple)
zeros([T=Float64,] dims...)
```
Create an `Array`, with element type `T`, of all zeros with size specified by `dims`. See also [`fill`](#Base.fill), [`ones`](#Base.ones), [`zero`](../numbers/#Base.zero).
**Examples**
```julia-repl
julia> zeros(1)
1-element Vector{Float64}:
 0.0

julia> zeros(Int8, 2, 3)
2×3 Matrix{Int8}:
 0  0  0
 0  0  0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L540-L558)
```julia
ones([T=Float64,] dims::Tuple)
ones([T=Float64,] dims...)
```


## [Constructors and Types](#Constructors-and-Types)
Create an `Array`, with element type `T`, of all ones with size specified by `dims`. See also [`fill`](#Base.fill), [`zeros`](#Base.zeros).
**Examples**
```julia-repl
julia> ones(1,2)
1×2 Matrix{Float64}:
 1.0  1.0

julia> ones(ComplexF64, 2, 3)
2×3 Matrix{ComplexF64}:
 1.0+0.0im  1.0+0.0im  1.0+0.0im
 1.0+0.0im  1.0+0.0im  1.0+0.0im
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L561-L579)
```julia
BitArray{N} <: AbstractArray{Bool, N}
```
Space-efficient `N`-dimensional boolean array, using just one bit for each boolean value.
`BitArray`s pack up to 64 values into every 8 bytes, resulting in an 8x space efficiency over `Array{Bool, N}` and allowing some operations to work on 64 values at once.
By default, Julia returns `BitArrays` from [broadcasting](../../manual/arrays/#Broadcasting) operations that generate boolean elements (including dotted-comparisons like `.==`) as well as from the functions [`trues`](#Base.trues) and [`falses`](#Base.falses).
Due to its packed storage format, concurrent access to the elements of a `BitArray` where at least one of them is a write is not thread-safe.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bitarray.jl#L7-L23)
```julia
BitArray(undef, dims::Integer...)
BitArray{N}(undef, dims::NTuple{N,Int})
```
Construct an undef [`BitArray`](#Base.BitArray) with the given dimensions. Behaves identically to the [`Array`](#Core.Array) constructor. See [`undef`](#Core.undef).


## [Constructors and Types](#Constructors-and-Types)
**Examples**
```julia-repl
julia> BitArray(undef, 2, 2)
2×2 BitMatrix:
 0  0
 0  0

julia> BitArray(undef, (3, 1))
3×1 BitMatrix:
 0
 0
 0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bitarray.jl#L48-L68)
```julia
BitArray(itr)
```
Construct a [`BitArray`](#Base.BitArray) generated by the given iterable object. The shape is inferred from the `itr` object.
**Examples**
```julia-repl
julia> BitArray([1 0; 0 1])
2×2 BitMatrix:
 1  0
 0  1

julia> BitArray(x+y == 3 for x = 1:2, y = 1:3)
2×3 BitMatrix:
 0  1  0
 1  0  0

julia> BitArray(x+y == 3 for x = 1:2 for y = 1:3)
6-element BitVector:
 0
 1
 0
 1
 0
 0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bitarray.jl#L549-L576)
```julia
trues(dims)
```
Create a `BitArray` with all values set to `true`.
**Examples**
```julia-repl
julia> trues(2,3)
2×3 BitMatrix:
 1  1  1
 1  1  1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bitarray.jl#L408-L420)
```julia
falses(dims)
```
Create a `BitArray` with all values set to `false`.
**Examples**
```julia-repl
julia> falses(2,3)
2×3 BitMatrix:
 0  0  0
 0  0  0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bitarray.jl#L390-L402)
```julia
fill(value, dims::Tuple)
fill(value, dims...)
```
Create an array of size `dims` with every location set to `value`.


## [Constructors and Types](#Constructors-and-Types)
For example, `fill(1.0, (5,5))` returns a 5×5 array of floats, with `1.0` in every location of the array.
The dimension lengths `dims` may be specified as either a tuple or a sequence of arguments. An `N`-length tuple or `N` arguments following the `value` specify an `N`-dimensional array. Thus, a common idiom for creating a zero-dimensional array with its only location set to `x` is `fill(x)`.
Every location of the returned array is set to (and is thus [`===`](../base/#Core.:===) to) the `value` that was passed; this means that if the `value` is itself modified, all elements of the `fill`ed array will reflect that modification because they're *still* that very `value`. This is of no concern with `fill(1.0, (5,5))` as the `value` `1.0` is immutable and cannot itself be modified, but can be unexpected with mutable values like — most commonly — arrays. For example, `fill([], 3)` places *the very same* empty array in all three locations of the returned vector:
```julia-repl
julia> v = fill([], 3)
3-element Vector{Vector{Any}}:
 []
 []
 []

julia> v[1] === v[2] === v[3]
true

julia> value = v[1]
Any[]

julia> push!(value, 867_5309)
1-element Vector{Any}:
 8675309

julia> v
3-element Vector{Vector{Any}}:
 [8675309]
 [8675309]
 [8675309]
```
To create an array of many independent inner arrays, use a [comprehension](../../manual/arrays/#man-comprehensions) instead. This creates a new and distinct array on each iteration of the loop:


## [Constructors and Types](#Constructors-and-Types)
```julia-repl
julia> v2 = [[] for _ in 1:3]
3-element Vector{Vector{Any}}:
 []
 []
 []

julia> v2[1] === v2[2] === v2[3]
false

julia> push!(v2[1], 8675309)
1-element Vector{Any}:
 8675309

julia> v2
3-element Vector{Vector{Any}}:
 [8675309]
 []
 []
```
See also: [`fill!`](#Base.fill!), [`zeros`](#Base.zeros), [`ones`](#Base.ones), [`similar`](#Base.similar).
**Examples**
```julia-repl
julia> fill(1.0, (2,3))
2×3 Matrix{Float64}:
 1.0  1.0  1.0
 1.0  1.0  1.0

julia> fill(42)
0-dimensional Array{Int64, 0}:
42

julia> A = fill(zeros(2), 2) # sets both elements to the same [0.0, 0.0] vector
2-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [0.0, 0.0]

julia> A[1][1] = 42; # modifies the filled value to be [42.0, 0.0]

julia> A # both A[1] and A[2] are the very same vector
2-element Vector{Vector{Float64}}:
 [42.0, 0.0]
 [42.0, 0.0]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L437-L532)
```julia
fill!(A, x)
```
Fill array `A` with the value `x`. If `x` is an object reference, all elements will refer to the same object. `fill!(A, Foo())` will return `A` filled with the result of evaluating `Foo()` once.
**Examples**


## [Constructors and Types](#Constructors-and-Types)
```julia-repl
julia> A = zeros(2,3)
2×3 Matrix{Float64}:
 0.0  0.0  0.0
 0.0  0.0  0.0

julia> fill!(A, 2.)
2×3 Matrix{Float64}:
 2.0  2.0  2.0
 2.0  2.0  2.0

julia> a = [1, 1, 1]; A = fill!(Vector{Vector{Int}}(undef, 3), a); a[1] = 2; A
3-element Vector{Vector{Int64}}:
 [2, 1, 1]
 [2, 1, 1]
 [2, 1, 1]

julia> x = 0; f() = (global x += 1; x); fill!(Vector{Int}(undef, 3), f())
3-element Vector{Int64}:
 1
 1
 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/multidimensional.jl#L1109-L1140)
```julia
empty(x::Tuple)
```
Return an empty tuple, `()`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/tuple.jl#L685-L689)
```julia
empty(v::AbstractVector, [eltype])
```
Create an empty vector similar to `v`, optionally changing the `eltype`.
See also: [`empty!`](../collections/#Base.empty!), [`isempty`](../collections/#Base.isempty), [`isassigned`](#Base.isassigned).
**Examples**
```julia-repl
julia> empty([1.0, 2.0, 3.0])
Float64[]

julia> empty([1.0, 2.0, 3.0], String)
String[]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L870-L886)
```julia
empty(a::AbstractDict, [index_type=keytype(a)], [value_type=valtype(a)])
```


## [Constructors and Types](#Constructors-and-Types)
Create an empty `AbstractDict` container which can accept indices of type `index_type` and values of type `value_type`. The second and third arguments are optional and default to the input's `keytype` and `valtype`, respectively. (If only one of the two types is specified, it is assumed to be the `value_type`, and the `index_type` we default to `keytype(a)`).
Custom `AbstractDict` subtypes may choose which specific dictionary type is best suited to return for the given index and value types, by specializing on the three-argument signature. The default is to return an empty `Dict`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L182-L193)
```julia
similar(A::AbstractSparseMatrixCSC{Tv,Ti}, [::Type{TvNew}, ::Type{TiNew}, m::Integer, n::Integer]) where {Tv,Ti}
```
Create an uninitialized mutable array with the given element type, index type, and size, based upon the given source `SparseMatrixCSC`. The new sparse matrix maintains the structure of the original sparse matrix, except in the case where dimensions of the output matrix are different from the output.
The output matrix has zeros in the same locations as the input, but uninitialized values for the nonzero locations.
```julia
similar(array, [element_type=eltype(array)], [dims=size(array)])
```


## [Constructors and Types](#Constructors-and-Types)
Create an uninitialized mutable array with the given element type and size, based upon the given source array. The second and third arguments are both optional, defaulting to the given array's `eltype` and `size`. The dimensions may be specified either as a single tuple argument or as a series of integer arguments.
Custom AbstractArray subtypes may choose which specific array type is best-suited to return for the given element type and dimensionality. If they do not specialize this method, the default is an `Array{element_type}(undef, dims...)`.
For example, `similar(1:10, 1, 4)` returns an uninitialized `Array{Int,2}` since ranges are neither mutable nor support 2 dimensions:
```julia-repl
julia> similar(1:10, 1, 4)
1×4 Matrix{Int64}:
 4419743872  4374413872  4419743888  0
```
Conversely, `similar(trues(10,10), 2)` returns an uninitialized `BitVector` with two elements since `BitArray`s are both mutable and can support 1-dimensional arrays:
```julia-repl
julia> similar(trues(10,10), 2)
2-element BitVector:
 0
 0
```
Since `BitArray`s can only store elements of type [`Bool`](../numbers/#Core.Bool), however, if you request a different element type it will create a regular `Array` instead:
```julia-repl
julia> similar(falses(10), Float64, 2, 4)
2×4 Matrix{Float64}:
 2.18425e-314  2.18425e-314  2.18425e-314  2.18425e-314
 2.18425e-314  2.18425e-314  2.18425e-314  2.18425e-314
```
See also: [`undef`](#Core.undef), [`isassigned`](#Base.isassigned).


## [Constructors and Types](#Constructors-and-Types)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L777-L819)
```julia
similar(storagetype, axes)
```
Create an uninitialized mutable array analogous to that specified by `storagetype`, but with `axes` specified by the last argument.
**Examples**:
```julia
similar(Array{Int}, axes(A))
```
creates an array that "acts like" an `Array{Int}` (and might indeed be backed by one), but which is indexed identically to `A`. If `A` has conventional indexing, this will be identical to `Array{Int}(undef, size(A))`, but if `A` has unconventional indexing then the indices of the result will match `A`.
```julia
similar(BitArray, (axes(A, 2),))
```
would create a 1-dimensional logical array whose indices match those of the columns of `A`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L844-L865)


## [Basic functions](#Basic-functions)
```julia
ndims(A::AbstractArray) -> Integer
```
Return the number of dimensions of `A`.
See also: [`size`](#Base.size), [`axes`](#Base.axes-Tuple%7BAny%7D).
**Examples**
```julia-repl
julia> A = fill(1, (3,4,5));

julia> ndims(A)
3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L259-L273)
```julia
size(A::AbstractArray, [dim])
```
Return a tuple containing the dimensions of `A`. Optionally you can specify a dimension to just get the length of that dimension.
Note that `size` may not be defined for arrays with non-standard indices, in which case [`axes`](#Base.axes-Tuple%7BAny%7D) may be useful. See the manual chapter on [arrays with custom indices](../../devdocs/offset-arrays/#man-custom-indices).
See also: [`length`](../collections/#Base.length), [`ndims`](#Base.ndims), [`eachindex`](#Base.eachindex), [`sizeof`](../base/#Base.sizeof-Tuple%7BType%7D).
**Examples**
```julia-repl
julia> A = fill(1, (2,3,4));

julia> size(A)
(2, 3, 4)

julia> size(A, 2)
3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L20-L41)
```julia
axes(A)
```
Return the tuple of valid indices for array `A`.
See also: [`size`](#Base.size), [`keys`](../collections/#Base.keys), [`eachindex`](#Base.eachindex).
**Examples**
```julia-repl
julia> A = fill(1, (5,6,7));

julia> axes(A)
(Base.OneTo(5), Base.OneTo(6), Base.OneTo(7))
```


## [Basic functions](#Basic-functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L80-L95)
```julia
axes(A, d)
```
Return the valid range of indices for array `A` along dimension `d`.
See also [`size`](#Base.size), and the manual chapter on [arrays with custom indices](../../devdocs/offset-arrays/#man-custom-indices).
**Examples**
```julia-repl
julia> A = fill(1, (5,6,7));

julia> axes(A, 2)
Base.OneTo(6)

julia> axes(A, 4) == 1:1  # all dimensions d > ndims(A) have size 1
true
```
**Usage note**
Each of the indices has to be an `AbstractUnitRange{<:Integer}`, but at the same time can be a type that uses custom indices. So, for example, if you need a subset, use generalized indexing constructs like `begin`/`end` or [`firstindex`](../collections/#Base.firstindex)/[`lastindex`](../collections/#Base.lastindex):
```julia
ix = axes(v, 1)
ix[2:end]          # will work for eg Vector, but may fail in general
ix[(begin+1):end]  # works for generalized indexes
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L44-L74)
```julia
length(A::AbstractArray)
```
Return the number of elements in the array, defaults to `prod(size(A))`.
**Examples**
```julia-repl
julia> length([1, 2, 3, 4])
4

julia> length([1 2; 3 4])
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L301-L314)
```julia
keys(a::AbstractArray)
```


## [Basic functions](#Basic-functions)
Return an efficient array describing all valid indices for `a` arranged in the shape of `a` itself.
The keys of 1-dimensional arrays (vectors) are integers, whereas all other N-dimensional arrays use [`CartesianIndex`](#Base.IteratorsMD.CartesianIndex) to describe their locations. Often the special array types [`LinearIndices`](#Base.LinearIndices) and [`CartesianIndices`](#Base.IteratorsMD.CartesianIndices) are used to efficiently represent these arrays of integers and `CartesianIndex`es, respectively.
Note that the `keys` of an array might not be the most efficient index type; for maximum performance use [`eachindex`](#Base.eachindex) instead.
**Examples**
```julia-repl
julia> keys([4, 5, 6])
3-element LinearIndices{1, Tuple{Base.OneTo{Int64}}}:
 1
 2
 3

julia> keys([4 5; 6 7])
CartesianIndices((2, 2))
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L140-L164)
```julia
eachindex(A...)
eachindex(::IndexStyle, A::AbstractArray...)
```
Create an iterable object for visiting each index of an `AbstractArray` `A` in an efficient manner. For array types that have opted into fast linear indexing (like `Array`), this is simply the range `1:length(A)` if they use 1-based indexing. For array types that have not opted into fast linear indexing, a specialized Cartesian range is typically returned to efficiently index into the array with indices specified for every dimension.


## [Basic functions](#Basic-functions)
In general `eachindex` accepts arbitrary iterables, including strings and dictionaries, and returns an iterator object supporting arbitrary index types (e.g. unevenly spaced or non-integer indices).
If `A` is `AbstractArray` it is possible to explicitly specify the style of the indices that should be returned by `eachindex` by passing a value having `IndexStyle` type as its first argument (typically `IndexLinear()` if linear indices are required or `IndexCartesian()` if Cartesian range is wanted).
If you supply more than one `AbstractArray` argument, `eachindex` will create an iterable object that is fast for all arguments (typically a [`UnitRange`](../collections/#Base.UnitRange) if all inputs have fast linear indexing, a [`CartesianIndices`](#Base.IteratorsMD.CartesianIndices) otherwise). If the arrays have different sizes and/or dimensionalities, a `DimensionMismatch` exception will be thrown.
See also [`pairs`](../collections/#Base.pairs)`(A)` to iterate over indices and values together, and [`axes`](#Base.axes-Tuple%7BAny%7D)`(A, 2)` for valid indices along one dimension.
**Examples**
```julia-repl
julia> A = [10 20; 30 40];

julia> for i in eachindex(A) # linear indexing
           println("A[", i, "] == ", A[i])
       end
A[1] == 10
A[2] == 30
A[3] == 20
A[4] == 40

julia> for i in eachindex(view(A, 1:2, 1:1)) # Cartesian indexing
           println(i)
       end
CartesianIndex(1, 1)
CartesianIndex(2, 1)
```


## [Basic functions](#Basic-functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L331-L377)
```julia
IndexStyle(A)
IndexStyle(typeof(A))
```
`IndexStyle` specifies the "native indexing style" for array `A`. When you define a new [`AbstractArray`](#Core.AbstractArray) type, you can choose to implement either linear indexing (with [`IndexLinear`](#Base.IndexLinear)) or cartesian indexing. If you decide to only implement linear indexing, then you must set this trait for your array type:
```julia
Base.IndexStyle(::Type{<:MyArray}) = IndexLinear()
```
The default is [`IndexCartesian()`](#Base.IndexCartesian).
Julia's internal indexing machinery will automatically (and invisibly) recompute all indexing operations into the preferred style. This allows users to access elements of your array using any indexing style, even when explicit methods have not been provided.
If you define both styles of indexing for your `AbstractArray`, this trait can be used to select the most performant indexing style. Some methods check this trait on their inputs, and dispatch to different algorithms depending on the most efficient access pattern. In particular, [`eachindex`](#Base.eachindex) creates an iterator whose type depends on the setting of this trait.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/indices.jl#L68-L93)
```julia
IndexLinear()
```
Subtype of [`IndexStyle`](#Base.IndexStyle) used to describe arrays which are optimally indexed by one linear index.


## [Basic functions](#Basic-functions)
A linear indexing style uses one integer index to describe the position in the array (even if it's a multidimensional array) and column-major ordering is used to efficiently access the elements. This means that requesting [`eachindex`](#Base.eachindex) from an array that is `IndexLinear` will return a simple one-dimensional range, even if it is multidimensional.
A custom array that reports its `IndexStyle` as `IndexLinear` only needs to implement indexing (and indexed assignment) with a single `Int` index; all other indexing expressions — including multidimensional accesses — will be recomputed to the linear index. For example, if `A` were a `2×3` custom matrix with linear indexing, and we referenced `A[1, 3]`, this would be recomputed to the equivalent linear index and call `A[5]` since `1 + 2*(3 - 1) = 5`.
See also [`IndexCartesian`](#Base.IndexCartesian).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/indices.jl#L16-L36)
```julia
IndexCartesian()
```
Subtype of [`IndexStyle`](#Base.IndexStyle) used to describe arrays which are optimally indexed by a Cartesian index. This is the default for new custom [`AbstractArray`](#Core.AbstractArray) subtypes.
A Cartesian indexing style uses multiple integer indices to describe the position in a multidimensional array, with exactly one index per dimension. This means that requesting [`eachindex`](#Base.eachindex) from an array that is `IndexCartesian` will return a range of [`CartesianIndices`](#Base.IteratorsMD.CartesianIndices).


## [Basic functions](#Basic-functions)
A `N`-dimensional custom array that reports its `IndexStyle` as `IndexCartesian` needs to implement indexing (and indexed assignment) with exactly `N` `Int` indices; all other indexing expressions — including linear indexing — will be recomputed to the equivalent Cartesian location. For example, if `A` were a `2×3` custom matrix with cartesian indexing, and we referenced `A[5]`, this would be recomputed to the equivalent Cartesian index and call `A[1, 3]` since `5 = 1 + 2*(3 - 1)`.
It is significantly more expensive to compute Cartesian indices from a linear index than it is to go the other way. The former operation requires division — a very costly operation — whereas the latter only uses multiplication and addition and is essentially free. This asymmetry means it is far more costly to use linear indexing with an `IndexCartesian` array than it is to use Cartesian indexing with an `IndexLinear` array.
See also [`IndexLinear`](#Base.IndexLinear).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/indices.jl#L39-L65)
```julia
conj!(A)
```
Transform an array to its complex conjugate in-place.
See also [`conj`](../math/#Base.conj).
**Examples**
```julia-repl
julia> A = [1+im 2-im; 2+2im 3+im]
2×2 Matrix{Complex{Int64}}:
 1+1im  2-1im
 2+2im  3+1im

julia> conj!(A);

julia> A
2×2 Matrix{Complex{Int64}}:
 1-1im  2+1im
 2-2im  3-1im
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L98-L119)
```julia
stride(A, k::Integer)
```


## [Basic functions](#Basic-functions)
Return the distance in memory (in number of elements) between adjacent elements in dimension `k`.
See also: [`strides`](#Base.strides).
**Examples**
```julia-repl
julia> A = fill(1, (3,4,5));

julia> stride(A,2)
3

julia> stride(A,3)
12
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L576-L593)
```julia
strides(A)
```
Return a tuple of the memory strides in each dimension.
See also: [`stride`](#Base.stride).
**Examples**
```julia-repl
julia> A = fill(1, (3,4,5));

julia> strides(A)
(1, 3, 12)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L559-L573)


## [Broadcast and vectorization](#Broadcast-and-vectorization)
See also the [dot syntax for vectorizing functions](../../manual/functions/#man-vectorized); for example, `f.(args...)` implicitly calls `broadcast(f, args...)`. Rather than relying on "vectorized" methods of functions like `sin` to operate on arrays, you should use `sin.(a)` to vectorize via `broadcast`.
```julia
broadcast(f, As...)
```
Broadcast the function `f` over the arrays, tuples, collections, [`Ref`](../c/#Core.Ref)s and/or scalars `As`.
Broadcasting applies the function `f` over the elements of the container arguments and the scalars themselves in `As`. Singleton and missing dimensions are expanded to match the extents of the other arguments by virtually repeating the value. By default, only a limited number of types are considered scalars, including `Number`s, `String`s, `Symbol`s, `Type`s, `Function`s and some common singletons like [`missing`](../../manual/missing/#missing) and [`nothing`](../constants/#Core.nothing). All other arguments are iterated over or indexed into elementwise.
The resulting container type is established by the following rules:
-   If all the arguments are scalars or zero-dimensional arrays, it returns an unwrapped scalar.
-   If at least one argument is a tuple and all others are scalars or zero-dimensional arrays, it returns a tuple.
-   All other combinations of arguments default to returning an `Array`, but custom container types can define their own implementation and promotion-like rules to customize the result when they appear as arguments.


## [Broadcast and vectorization](#Broadcast-and-vectorization)
A special syntax exists for broadcasting: `f.(args...)` is equivalent to `broadcast(f, args...)`, and nested `f.(g.(args...))` calls are fused into a single broadcast loop.
**Examples**
```julia-repl
julia> A = [1, 2, 3, 4, 5]
5-element Vector{Int64}:
 1
 2
 3
 4
 5

julia> B = [1 2; 3 4; 5 6; 7 8; 9 10]
5×2 Matrix{Int64}:
 1   2
 3   4
 5   6
 7   8
 9  10

julia> broadcast(+, A, B)
5×2 Matrix{Int64}:
  2   3
  5   6
  8   9
 11  12
 14  15

julia> parse.(Int, ["1", "2"])
2-element Vector{Int64}:
 1
 2

julia> abs.((1, -2))
(1, 2)

julia> broadcast(+, 1.0, (0, -2.0))
(1.0, -1.0)

julia> (+).([[0,2], [1,3]], Ref{Vector{Int}}([1,-1]))
2-element Vector{Vector{Int64}}:
 [1, 1]
 [2, 2]

julia> string.(("one","two","three","four"), ": ", 1:4)
4-element Vector{String}:
 "one: 1"
 "two: 2"
 "three: 3"
 "four: 4"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L734-L809)
```julia
broadcast!(f, dest, As...)
```
Like [`broadcast`](#Base.Broadcast.broadcast), but store the result of `broadcast(f, As...)` in the `dest` array. Note that `dest` is only used to store the result, and does not supply arguments to `f` unless it is also listed in the `As`, as in `broadcast!(f, A, A, B)` to perform `A[:] = broadcast(f, A, B)`.
**Examples**


## [Broadcast and vectorization](#Broadcast-and-vectorization)
```julia-repl
julia> A = [1.0; 0.0]; B = [0.0; 0.0];

julia> broadcast!(+, B, A, (0, -2.0));

julia> B
2-element Vector{Float64}:
  1.0
 -2.0

julia> A
2-element Vector{Float64}:
 1.0
 0.0

julia> broadcast!(+, A, A, (0, -2.0));

julia> A
2-element Vector{Float64}:
  1.0
 -2.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L816-L848)
```julia
@. expr
```
Convert every function call or operator in `expr` into a "dot call" (e.g. convert `f(x)` to `f.(x)`), and convert every assignment in `expr` to a "dot assignment" (e.g. convert `+=` to `.+=`).
If you want to *avoid* adding dots for selected function calls in `expr`, splice those function calls in with `$`. For example, `@. sqrt(abs($sort(x)))` is equivalent to `sqrt.(abs.(sort(x)))` (no dot for `sort`).
(`@.` is equivalent to a call to `@__dot__`.)
**Examples**
```julia-repl
julia> x = 1.0:3.0; y = similar(x);

julia> @. y = x + 3 * sin(x)
3-element Vector{Float64}:
 3.5244129544236893
 4.727892280477045
 3.4233600241796016
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L1278-L1302)
For specializing broadcast on custom types, see
`BroadcastStyle` is an abstract type and trait-function used to determine behavior of objects under broadcasting. `BroadcastStyle(typeof(x))` returns the style associated with `x`. To customize the broadcasting behavior of a type, one can declare a style by defining a type/method pair


## [Broadcast and vectorization](#Broadcast-and-vectorization)
```julia
struct MyContainerStyle <: BroadcastStyle end
Base.BroadcastStyle(::Type{<:MyContainer}) = MyContainerStyle()
```
One then writes method(s) (at least [`similar`](#Base.similar)) operating on `Broadcasted{MyContainerStyle}`. There are also several pre-defined subtypes of `BroadcastStyle` that you may be able to leverage; see the [Interfaces chapter](../../manual/interfaces/#man-interfaces-broadcasting) for more information.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L21-L34)
`Broadcast.AbstractArrayStyle{N} <: BroadcastStyle` is the abstract supertype for any style associated with an `AbstractArray` type. The `N` parameter is the dimensionality, which can be handy for AbstractArray types that only support specific dimensionalities:
```julia
struct SparseMatrixStyle <: Broadcast.AbstractArrayStyle{2} end
Base.BroadcastStyle(::Type{<:SparseMatrixCSC}) = SparseMatrixStyle()
```
For `AbstractArray` types that support arbitrary dimensionality, `N` can be set to `Any`:
```julia
struct MyArrayStyle <: Broadcast.AbstractArrayStyle{Any} end
Base.BroadcastStyle(::Type{<:MyArray}) = MyArrayStyle()
```
In cases where you want to be able to mix multiple `AbstractArrayStyle`s and keep track of dimensionality, your style needs to support a [`Val`](../base/#Base.Val) constructor:
```julia
struct MyArrayStyleDim{N} <: Broadcast.AbstractArrayStyle{N} end
(::Type{<:MyArrayStyleDim})(::Val{N}) where N = MyArrayStyleDim{N}()
```


## [Broadcast and vectorization](#Broadcast-and-vectorization)
Note that if two or more `AbstractArrayStyle` subtypes conflict, broadcasting machinery will fall back to producing `Array`s. If this is undesirable, you may need to define binary [`BroadcastStyle`](#Base.Broadcast.BroadcastStyle) rules to control the output type.
See also [`Broadcast.DefaultArrayStyle`](#Base.Broadcast.DefaultArrayStyle).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L51-L76)
`Broadcast.ArrayStyle{MyArrayType}()` is a [`BroadcastStyle`](#Base.Broadcast.BroadcastStyle) indicating that an object behaves as an array for broadcasting. It presents a simple way to construct [`Broadcast.AbstractArrayStyle`](#Base.Broadcast.AbstractArrayStyle)s for specific `AbstractArray` container types. Broadcast styles created this way lose track of dimensionality; if keeping track is important for your type, you should create your own custom [`Broadcast.AbstractArrayStyle`](#Base.Broadcast.AbstractArrayStyle).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L79-L85)