# copytext proc

Source: https://ref.dm-lang.org/proc/copytext

### Format
> `copytext(T,Start=1,End=0)`

### Returns
> A text string.

### Args
- `T`: A text string.
- `Start`: The text byte position in which to begin the copy.
- `End`: The text byte position immediately following the last character to be copied.


Copy characters in T between Start and End. The default end position of 0 stands for `length(T)+1`, so by default the entire text string is copied.

```dm /copytext/
pre = copytext("Hi there",1,3))// = "Hi"
post = copytext("Hi there",4)) // = "there"
```

If the start or end position is negative, it counts backwards from the end of the string.

```dm /copytext/
post = copytext("Hi there",-5)) // = "there"
```

> [!note]
> 
> In strings containing non-ASCII characters, byte position and character position are not the same thing. Use `copytext_char()` to work with character counts instead of bytes, at a performance cost. See the [Unicode](https://ref.dm-lang.org/notes/Unicode.md) section for more information.

### See also
- [splicetext proc](https://ref.dm-lang.org/proc/splicetext.md)
- [findtext proc](https://ref.dm-lang.org/proc/findtext.md)
- [splittext proc](https://ref.dm-lang.org/proc/splittext.md)
- [trimtext proc](https://ref.dm-lang.org/proc/trimtext.md)
- [Copy proc (list)](https://ref.dm-lang.org/list/proc/Copy.md)
