> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/string/right.md).

# Right

Extract the rightmost count characters from a string

## Method Signature

```
Right(string=[string], count=[integer])
```

### Arguments

| Argument | Type      | Required | Description                           | Default |
| -------- | --------- | -------- | ------------------------------------- | ------- |
| `string` | `string`  | `true`   | The string to extract from            |         |
| `count`  | `integer` | `true`   | The number of characters to retrieve. |         |

## Examples

### Using right() on a string

In this example we'll use right() to return part of a string.

[Run Example](https://try.boxlang.io/?code=eJwrL8osSfUvLSkoLdFQKMpMzwBSSiEZqQqFpZnJ2QpJRfnleQpp%2BRUKWaW5BakpCvllqUUKJUD5nMSqSoWU%2FHQlHQULBU0FTWsuAAmGGTk%3D)

```java
writeOutput( right( "The quick brown fox jumped over the lazy dog", 8 ) );

```

Result: lazy dog

### Using right() with a negative count on a string

In this example we'll use a negative count right() to return part of a string.

[Run Example](https://try.boxlang.io/?code=eJwrL8osSfUvLSkoLdFQKMpMzwBSSiEZqQqFpZnJ2QpJRfnleQpp%2BRUKWaW5BakpCvllqUUKJUD5nMSqSoWU%2FHQlHQVdYyMFTQVNay4APN0Zkw%3D%3D)

```java
writeOutput( right( "The quick brown fox jumped over the lazy dog", -32 ) );

```

Result: the lazy dog

### Using right() in a function

In this example we'll use right() in a function to help us to capitalize the last letter in a string.

[Run Example](https://try.boxlang.io/?code=eJxtjLEKAkEMBWv3K1KJBypYW4qd5RXXxjW3BtZ4ZhMQxX83FjZi84ph5qXJj5UzNFOWAqNLNr4KZJzYsPKDDthsAUo3Z6XTVzS6G3TwTDMlcxWoNIaGWvxCYm3d74d%2BGVR%2BYVQr2MTOwXfYKL65nP%2B0H6fbpld6A7RHNk4%3D)

```java

public string function capitalizeLast( required string text ) {
	return left( arguments.TEXT, len( arguments.TEXT ) - 1 ) & uCase( right( arguments.TEXT, 1 ) );
}

```

### Using right() to test values

In this example we'll use right() to test the last five characters of a request context variable.

```java
if( listFindNoCase( "super,great,coder,rulez", right( rc.ANSWER, 5 ) ) ) {
	writeOutput( "You are an awesome developer!" );
}

```

### Using right() as a member function

In this example we'll use right() as a member function inside a function to help us to capitalize the last letter in a string.

[Run Example](https://try.boxlang.io/?code=eJxly6EOQjEMhWHNnqKKbIIlaDQOeQW2jN7RZJRL1yYEwrszgwF7%2FvOFxU%2BNC3RTlgqzSzG%2BCRRc2LDxkw7YLYLS3Vnp%2FD0aPQwSvMJKyVwFUKtfSaznaX%2BccqN5qL9RYoINbIdc%2F0blehlktOwFO8W0C%2B%2FwAf%2FtNg4%3D)

```java

public string function capitalizeLast( required string text ) {
	return arguments.TEXT.left( arguments.TEXT.len() - 1 ) & arguments.TEXT.right( 1 ).ucase();
}

```

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJx1jcsKwjAQRff5iktWLZQGFFfFnQguXPkFtUxNII8ymejvm%2FoAN%2B4OF849xiC7sHjCscRJXIrqwU7oUMLSgN3NSgN9gk93gi8Tke6wQ4t2gDHvRVU4U7gSY%2F6eZGHsoS9j1YSJcoe8snczIUWIJdDIYns9%2FBar13%2Bqm%2B0ro9bOH1c9AQSvPJg%3D)

```java
// simple Function
writeDump( right( "I love boxlang", 5 ) ); // boxlang
// Member function
str = "Save trees, save life on the earth.";
writeDump( str.right( 23 ) );
 // save life on the earth.

```

## Related

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
