> 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/val.md).

# Val

Converts numeric characters and the first period found that occur at the beginning of a string to a number.

A period not accompianied by at least one numeric digit will be ignored. If no numeric digits are found at the start of the string, zero will be returned.

## Method Signature

```
Val(string=[string])
```

### Arguments

| Argument | Type     | Required | Description         | Default |
| -------- | -------- | -------- | ------------------- | ------- |
| `string` | `string` | `true`   | The string to parse |         |

## Examples

### Numeric characters at beginning and middle of a string

[Run Example](https://try.boxlang.io/?code=eJwrS8zRUFAyNDIoSS0uMTQqLi4pysxLV1LQtOYCAHXFCB4%3D)

```java
val( "120test12sstring" );

```

Result: 120

### Numeric characters only at the end of a string

[Run Example](https://try.boxlang.io/?code=eJwrS8zRUFAqLinKzEu3tFBS0LTmAgA9cAVm)

```java
val( "string98" );

```

Result: 0

### Additional Examples

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

```java
dump( Val( "1234 Main St." ) ); // 1234
dump( Val( "Main St., 1234" ) ); // 0
dump( Val( "123.456" ) ); // 123.456
dump( Val( "" ) ); // 0
dump( Val( "1" ) ); // 1
dump( Val( "one" ) ); // 0
dump( Val( "123T456" ) );
 // 123

```

## 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)
* [Right](/boxlang-language/reference/built-in-functions/string/right.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)
* [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)
* [StripCR](/boxlang-language/reference/built-in-functions/string/stripcr.md)
* [Trim](/boxlang-language/reference/built-in-functions/string/trim.md)
* [TrueFalseFormat](/boxlang-language/reference/built-in-functions/string/truefalseformat.md)
* [UCase](/boxlang-language/reference/built-in-functions/string/ucase.md)
* [UCFirst](/boxlang-language/reference/built-in-functions/string/ucfirst.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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
