> For the complete documentation index, see [llms.txt](https://docs.fortifiedid.se/expressions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fortifiedid.se/expressions/extensions/str.md).

# str

The str extension contains string helper function for validation and comparison.

## size

Returns the size/length of a string. If the supplied value isn't a string, -1 is returned.

### Syntax

`str.size(value)`

### Arguments

<table><thead><tr><th width="160">Name</th><th width="181">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>string</code></td><td>The string whose length is calculated and returned.  If empty, <code>0</code> is returned. If null, undefined or not a string, <code>-1</code> is returned.</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### Example(s)

```
// Check if value is a string and larger than 3 characters
str.size(scope.value) > 3
```

## isString

Returns `true` if the supplied value is a string, otherwise `false`.

### Syntax

`str.isString(value)`

### Arguments

<table><thead><tr><th width="160">Name</th><th width="181">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>string</code></td><td>The value to check</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### Example(s)

```
str.isString('this is a string') // true
str.isString(99) // false (number)
```

## isNullOrEmpty

Returns `true` if the supplied value is `null`/`undefined` or an empty string (`""`).

### Syntax

`str.isNullOrEmpty(value)`

### Arguments

<table><thead><tr><th width="160">Name</th><th width="181">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>string</code></td><td>The value to check</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### Example(s)

```
str.isNullOrEmpty(null) // true
str.isNullOrEmpty("") // true
str.isNullOrEmpty('this is a string') // false
```

## isNotNullOrEmpty

Returns `true` if the supplied value is a string and is *not* `null`/`undefined` or empty (`""`).

### Syntax

`str.isNotNullOrEmpty(value)`

### Arguments

<table><thead><tr><th width="160">Name</th><th width="181">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>string</code></td><td>The value to check</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### Example(s)

```
str.isNotNullOrEmpty(null) // false
str.isNotNullOrEmpty("") // false
str.isNotNullOrEmpty('this is a string') // true
```

## isEqual

Returns `true` if the supplied values are strings with identical content, possible with different case.

### Syntax

`str.isEqual(s1, s2[, ignoreCase])`

### Arguments

<table><thead><tr><th width="160">Name</th><th width="181">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>s1</code></td><td><code>string</code></td><td>The first string to compare for equality</td></tr><tr><td><code>s2</code></td><td><code>string</code></td><td>The second string to compare for equality</td></tr><tr><td><code>ignoreCase</code></td><td><code>boolean</code></td><td>Flag turning on case-insensitive compare (default: <code>false</code>)</td></tr></tbody></table>

### Example(s)

```
str.isEqual('string value', 'string value') // true
str.isEqual('string value', 'other string value') // false
str.isEqual('string value', 'STRING VALUE') // false
str.isEqual('string value', 'STRING VALUE', true) // true
```

## isEqualIgnoreCase

Returns `true` if the supplied values are strings with identical content, always ignoring different case.

This function is equivalent to `str.isEqual(s1, s2, true)`

### Syntax

`str.isEqualIgnoreCase(s1, s2)`

### Arguments

<table><thead><tr><th width="160">Name</th><th width="181">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>s1</code></td><td><code>string</code></td><td>The first string to compare for equality</td></tr><tr><td><code>s2</code></td><td><code>string</code></td><td>The second string to compare for equality</td></tr></tbody></table>

### Example(s)

```
str.isEqualIgnoreCase('string value', 'string value') // true
str.isEqualIgnoreCase('string value', 'other string value') // false
str.isEqualIgnoreCase('string value', 'STRING VALUE') // true
```

## matchAny

Returns `true` if the supplied value match any of the supplied regular expressions (regex).

### Syntax

`str.matchAny(value, regex[,regex, ...])`

### Arguments

<table><thead><tr><th width="160">Name</th><th width="181">Type</th><th>Description</th></tr></thead><tbody><tr><td>value</td><td><code>string</code></td><td>The value to match</td></tr><tr><td>regex</td><td><code>string | regex</code></td><td>One or more regular expressions used for matching.</td></tr></tbody></table>

### Example(s)

```
// plain string regex
str.matchAny('value', 'v.*') // true

// typed regex (format: /regex/flags)
str.matchAny('value', /v.*/) // true
str.matchAny('value', /[0-9]{1,3}/) // false

// case insensitive match using i-flag
str.matchAny('value', /V.*/i) // true 
```
