# Wrap

Wraps a string at the specified limit, breaking at the last space within the limit.

## Method Signature

```
Wrap(string=[string], limit=[integer], strip=[boolean])
```

### Arguments

| Argument | Type      | Required | Description                                                                       | Default |
| -------- | --------- | -------- | --------------------------------------------------------------------------------- | ------- |
| `string` | `string`  | `true`   | The string to wrap.                                                               |         |
| `limit`  | `integer` | `true`   | The character limit at which to wrap the string.                                  |         |
| `strip`  | `boolean` | `false`  | If true, replaces all line endings with spaces before wrapping. Default is false. | `false` |

## Examples

### Script Syntax

[Run Example](https://try.boxlang.io/?code=eJwrTs0rSc1LTlWwVVAKycgsVgCiRIXiksS8lMSiFIViqLSekjVXeVFiQUFqSjBCB0hEA65GR8FcQROkLLMk1b%2B0pKC0REMBXQ9QHgDmUSdM)

```java
sentence = "This is a standard sentence.";
wrappedSentence = wrap( sentence, 7 );
writeOutput( wrappedSentence );

```

Result: This is a standar d senten ce.

### Tag Syntax

```java
<bx:set sentence = "This is a standard sentence." >
<bx:set wrappedSentence = wrap( sentence, 7 ) >
<bx:output>#wrappedSentence#</bx:output>
```

Result: This is a standar d senten ce.

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxFjksLwjAQhO%2F%2BiiEHacEXXn2AV8GrV0nbNVnYJiFZLf33tnrwNMyDj5EY3KNo5uBwgrlA2HldDzQLujHYnluUNnPSeSM2uJd1hGfMUE%2B43m%2BTWgUF2wiVb5ht4g4dvUli6iko4hOF%2ByQEjfATXEaUmDwX5dYqdRiogU1JZssxlI05LKj1sYI5pkxngyWGCVxB%2Fp9X2O9QT405bn%2Bj%2BrD4AN3XSNI%3D)

```java
long_string = "A light-weight dynamic scripting language for the JVM that enables the rapid development of simple to highly sophisticated web applications.";
echo( "<pre>" & wrap( long_string, 20 ) & "</pre>" );

```

## Related

* [Ascii](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/ascii)
* [CamelCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/camelcase)
* [Char](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/char)
* [CharsetDecode](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/charsetdecode)
* [CharsetEncode](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/charsetencode)
* [Compare](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/compare)
* [CompareNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/comparenocase)
* [Find](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/find)
* [FindNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/findnocase)
* [FindOneOf](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/findoneof)
* [Insert](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/insert)
* [JSStringFormat](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/jsstringformat)
* [Justify](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/justify)
* [KebabCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/kebabcase)
* [LCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/lcase)
* [Left](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/left)
* [ListReduce](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/listreduce)
* [LJustify](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/ljustify)
* [LTrim](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/ltrim)
* [Mid](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/mid)
* [ParagraphFormat](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/paragraphformat)
* [PascalCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/pascalcase)
* [QueryStringToStruct](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/querystringtostruct)
* [ReEscape](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/reescape)
* [ReFind](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/refind)
* [reFindNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/refindnocase)
* [ReMatch](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/rematch)
* [reMatchNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/rematchnocase)
* [RemoveChars](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/removechars)
* [RepeatString](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/repeatstring)
* [Replace](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/replace)
* [ReplaceList](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/replacelist)
* [ReplaceListNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/replacelistnocase)
* [ReplaceNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/replacenocase)
* [ReReplace](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/rereplace)
* [reReplaceNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/rereplacenocase)
* [Reverse](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/reverse)
* [Right](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/right)
* [RJustify](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/rjustify)
* [RTrim](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/rtrim)
* [Slugify](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/slugify)
* [SnakeCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/snakecase)
* [SpanExcluding](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/spanexcluding)
* [SpanIncluding](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/spanincluding)
* [SQLPrettify](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/sqlprettify)
* [StringBind](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stringbind)
* [StringEach](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stringeach)
* [StringEvery](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stringevery)
* [StringFilter](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stringfilter)
* [StringMap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stringmap)
* [StringReduce](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stringreduce)
* [StringReduceRight](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stringreduceright)
* [StringSome](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stringsome)
* [StringSort](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stringsort)
* [StripCR](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/stripcr)
* [Trim](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/trim)
* [TrueFalseFormat](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/truefalseformat)
* [UCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/ucase)
* [UCFirst](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/ucfirst)
* [Val](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/val)
* [YesNoFormat](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/yesnoformat)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/wrap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
