> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/s/substring.md).

# Substring

```ruby
var str = 'abcdefgh'
var n = 2
var m = 3
say str.substr(n, m)                    #=> cde
say str.substr(n)                       #=> cdefgh
say str.substr(0, -1)                   #=> abcdefg
say str.substr(str.index('d'), m)       #=> def
say str.substr(str.index('de'), m)      #=> def
```
