> For the complete documentation index, see [llms.txt](https://stage-precision.gitbook.io/grid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stage-precision.gitbook.io/grid/scripting/api-reference/utility-api/strings.md).

# Strings

### `StringContainsAnyOf()`

Checks whether a string contains at least one of the specified characters.

#### Syntax

```python
sp.util.StringContainsAnyOf(value, characters)
```

#### Parameters

| Parameter    | Type  | Description              |
| ------------ | ----- | ------------------------ |
| `value`      | `str` | String to check          |
| `characters` | `str` | Characters to search for |

#### Returns

`bool`

Returns `True` when at least one of the specified characters is present.

#### Example

```python
result = sp.util.StringContainsAnyOf(
    "Hello World",
    "xyzW"
)

print(result)
```

Result:

```
True
```

The character `W` is present in the source string.

Another example:

```python
result = sp.util.StringContainsAnyOf(
    "Hello World",
    "xyz"
)
```

returns:

```
False
```

### `StringContainsOnly()`

Checks whether a string contains only characters from the specified set.

#### Syntax

```python
sp.util.StringContainsOnly(value, characters)
```

#### Parameters

| Parameter    | Type  | Description        |
| ------------ | ----- | ------------------ |
| `value`      | `str` | String to check    |
| `characters` | `str` | Allowed characters |

#### Returns

`bool`

#### Example

```python
result = sp.util.StringContainsOnly(
    "AABBCC",
    "ABC"
)

print(result)
```

Result:

```
True
```

A value containing another character returns `False`:

```python
sp.util.StringContainsOnly(
    "ABCD",
    "ABC"
)
```

### `StringContainsLowerCase()`

Checks whether a string contains at least one lowercase character.

#### Syntax

```python
sp.util.StringContainsLowerCase(value)
```

#### Returns

`bool`

#### Example

```python
result = sp.util.StringContainsLowerCase(
    "Hello WORLD 123"
)
```

Result:

```
True
```

### `StringContainsUpperCase()`

Checks whether a string contains at least one uppercase character.

#### Syntax

```python
sp.util.StringContainsUpperCase(value)
```

#### Returns

`bool`

#### Example

```python
result = sp.util.StringContainsUpperCase(
    "Hello WORLD 123"
)
```

Result:

```
True
```

### `StringContainsWholeWord()`

Checks whether a complete word exists inside a string.

The comparison is case-sensitive.

#### Syntax

```python
sp.util.StringContainsWholeWord(value, word)
```

#### Parameters

| Parameter | Type  | Description           |
| --------- | ----- | --------------------- |
| `value`   | `str` | String to search      |
| `word`    | `str` | Complete word to find |

#### Returns

`bool`

#### Example

```python
result = sp.util.StringContainsWholeWord(
    "Hello WORLD Test",
    "WORLD"
)
```

returns:

```
True
```

The comparison is case-sensitive:

```python
sp.util.StringContainsWholeWord(
    "Hello WORLD Test",
    "world"
)
```

returns:

```
False
```

The searched value must also be a complete word:

```python
sp.util.StringContainsWholeWord(
    "Hello WORLDwide Test",
    "WORLD"
)
```

returns:

```
False
```

### `StringContainsWholeWordIgnoreCase()`

Checks whether a complete word exists inside a string while ignoring character case.

#### Syntax

```python
sp.util.StringContainsWholeWordIgnoreCase(value, word)
```

#### Parameters

| Parameter | Type  | Description           |
| --------- | ----- | --------------------- |
| `value`   | `str` | String to search      |
| `word`    | `str` | Complete word to find |

#### Returns

`bool`

#### Example

```python
result = sp.util.StringContainsWholeWordIgnoreCase(
    "Hello WORLD Test",
    "world"
)
```

returns:

```
True
```

The searched value must still be a complete word:

```python
sp.util.StringContainsWholeWordIgnoreCase(
    "Hello WORLDwide Test",
    "world"
)
```

returns:

```
False
```

### `StringToLowerCase()`

Converts all characters in a string to lowercase.

#### Syntax

```python
sp.util.StringToLowerCase(value)
```

#### Returns

`str`

#### Example

```python
result = sp.util.StringToLowerCase(
    "Hello WORLD 123"
)

print(result)
```

Result:

```
hello world 123
```

### `StringToUpperCase()`

Converts all characters in a string to uppercase.

#### Syntax

```python
sp.util.StringToUpperCase(value)
```

#### Returns

`str`

#### Example

```python
result = sp.util.StringToUpperCase(
    "Hello WORLD 123"
)

print(result)
```

Result:

```
HELLO WORLD 123
```

### Quick Reference

| API                                              | Returns | Description                                          |
| ------------------------------------------------ | ------- | ---------------------------------------------------- |
| `StringContainsAnyOf(value, characters)`         | `bool`  | Checks whether any specified character is present    |
| `StringContainsOnly(value, characters)`          | `bool`  | Checks whether only specified characters are present |
| `StringContainsLowerCase(value)`                 | `bool`  | Checks for lowercase characters                      |
| `StringContainsUpperCase(value)`                 | `bool`  | Checks for uppercase characters                      |
| `StringContainsWholeWord(value, word)`           | `bool`  | Searches for a complete word, case-sensitive         |
| `StringContainsWholeWordIgnoreCase(value, word)` | `bool`  | Searches for a complete word, ignoring case          |
| `StringToLowerCase(value)`                       | `str`   | Converts a string to lowercase                       |
| `StringToUpperCase(value)`                       | `str`   | Converts a string to uppercase                       |
