> This page is for API Reference & Tools.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.moveworks.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.moveworks.com/_mcp/server.

# Examples: String Utils

## Evaluate a string with multiple elements

We want to evaluate a ticket description with multiple `STARTS_WITH`, but you do not want to write multiple `OR` operators in your rule that could make it bulky and hard to read. We can leverage the [ANY](/api-reference/configuration-languages/moveworks-dsl-reference#any) stream operator to match our ticket with a list of strings or elements.

You can also leverage the [ALL](/api-reference/configuration-languages/moveworks-dsl-reference#all) operator in case you want `AND` conditions.

### Given

```python
list_of_prefixes = ["Mr.", "Mrs.", "Dr."]

ticket.requestor.name = "Dr. Jane Doe"
```

### To check against all prefixes

```python
list_of_prefixes.$ANY(prefix => ticket.requestor.name.$STARTS_WITH(prefix))

# OR

["Mr.", "Mrs.", "Dr."].$ANY(prefix => ticket.requestor.name.$STARTS_WITH(prefix))
```

### Expected Result

```python
true
```

## String Special Character Detection

Check if a string contains any characters that are not alphabetic letters or whitespace.

### DSL Expression

```
text.$MATCH("[^a-zA-Z\\s]+", true).$LENGTH() > 0
```

**This DSL:**

* Searches for one or more consecutive non-letter, non-whitespace characters
* Returns `true` if any numbers or special characters are found
* Returns `false` if the string contains only letters and whitespace

### Use Cases

* Form validation to ensure text fields contain only alphabetic characters
* Identifying inputs that might require special handling or escaping
* Security checks for potentially unsafe character sequences

### Examples

| Input            | Result  | Reason                           |
| ---------------- | ------- | -------------------------------- |
| `"Hello world"`  | `false` | Contains only letters and spaces |
| `"Hello123"`     | `true`  | Contains numbers                 |
| `"Hello!"`       | `true`  | Contains special characters      |
| `"Hello world!"` | `true`  | Contains special characters      |

## Make all elements in a list lowercase

We usually create whitelists for users that want to test a certain skill or sometimes remove access to a list of people. We would want to evaluate all users in lowercase since sometimes emails or other attributes may contain capital letters. A way to lowercase an element is by using the `.$LOWERCASE()` formatter but it's not scalable if you have a list of hundreds of users. Here's how you can do it better.

### Given

```python
emails = ["HeLlo", "WoRld"]
```

### To lowercase all elements

```python
emails.$MAP(email => email.$LOWERCASE())

# or

["HeLlo", "WoRld"].$MAP(email => email.$LOWERCASE())
```

### Expected Result

```python
["hello", "world"]
```

## Generate a hyphenated "Random" Number

This expression creates a pseudo-random number string formatted as a hyphen-separated sequence.

```
$CONCAT([($TIME().$INTEGER() * 6).$TEXT()[7:12], ($TIME().$INTEGER() * 12).$TEXT()[7:12],($TIME().$INTEGER() * 7).$TEXT()[7:12],($TIME().$INTEGER() * 23).$TEXT()[7:12]],"-")
```

**This DSL:**

* Uses the current timestamp (`$TIME().$INTEGER()`) as a seed value
* Multiplies by different prime-like numbers (6, 12, 7, 23) to create variation
* Converts results to text and extracts specific digits using substring selection `[7:12]`
* Concatenates the four number segments with hyphens as separators

### How It Works

#### Get timestamp

`$TIME().$INTEGER()` gets the current Unix timestamp in milliseconds

#### Create variation

Multiplication by different factors produces varied number sequences

#### Extract digits

`.$TEXT()[7:12]` converts to text and extracts a consistent 4-digit segment

#### Join segments

`$CONCAT(..., "-")` joins the segments with hyphens

### Example Output

```
"3542-7084-5799-1911"
```

### Use Cases

* Generating reference numbers or transaction IDs
* Creating pseudo-random identifiers without requiring cryptographic security
* Producing readable, hyphenated codes for display purposes

> **Note**
>
> Not cryptographically secure -- uses deterministic operations on time values. Will produce different values on each evaluation as time changes.

\