Skip to content

Commit

Permalink
add SubStr to manual (#24125)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkamins authored and KristofferC committed Oct 13, 2017
1 parent 39f668c commit cbeab1a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions base/strings/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
Like [`getindex`](@ref), but returns a view into the parent string `s`
within range `i:j` or `r` respectively instead of making a copy.
# Examples
```jldoctest
julia> SubString("abc", 1, 2)
"ab"
julia> SubString("abc", 1:2)
"ab"
julia> SubString("abc", 2)
"bc"
"""
struct SubString{T<:AbstractString} <: AbstractString
string::T
Expand Down
4 changes: 2 additions & 2 deletions doc/src/manual/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ The former is a single character value of type `Char`, while the latter is a str
happens to contain only a single character. In Julia these are very different things.

Range indexing makes a copy of the selected part of the original string.
Alternatively, it is possible to create a view into a string using the type `SubString`,
Alternatively, it is possible to create a view into a string using the type [`SubString`](@ref),
for example:

```jldoctest
Expand All @@ -245,7 +245,7 @@ SubString{String}
```

Several standard functions like [`chop`](@ref), [`chomp`](@ref) or [`strip`](@ref)
return a `SubString`.
return a [`SubString`](@ref).

## Unicode and UTF-8

Expand Down
1 change: 1 addition & 0 deletions doc/src/stdlib/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Base.repeat(::AbstractString, ::Integer)
Base.repeat(::Char, ::Integer)
Base.repr
Core.String(::AbstractString)
Base.SubString
Base.transcode
Base.unsafe_string
Base.codeunit(::AbstractString, ::Integer)
Expand Down

0 comments on commit cbeab1a

Please sign in to comment.