Skip to content

Commit

Permalink
Add documentation of SubString (#23957)
Browse files Browse the repository at this point in the history
* Add documentation of SubString

`SubString` first appears in the section of regular expressions, but it is not mentioned earlier. I suggest to add documentation of `SubString` as it is returned by several functions from the standard library.

* moved to basics section

* improved the description
  • Loading branch information
bkamins authored and fredrikekre committed Oct 3, 2017
1 parent 522e725 commit f2b4ff5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions doc/src/manual/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,24 @@ julia> str[6:6]
The former is a single character value of type `Char`, while the latter is a string value that
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`,
for example:

```jldoctest
julia> str = "long string"
"long string"
julia> substr = SubString(str, 1, 4)
"long"
julia> typeof(substr)
SubString{String}
```

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

## Unicode and UTF-8

Julia fully supports Unicode characters and strings. As [discussed above](@ref man-characters), in character
Expand Down

0 comments on commit f2b4ff5

Please sign in to comment.