---
title: "String Operations"
description: "String manipulation — length, char/ord, concat, case conversion, trim, pos, substr, pad, match, replace, split, convert."
canonical_url: "https://www.zeyos.com/ixml/ixml-guide/syntax-essentials/strings"
markdown_url: "https://www.zeyos.com/ai/guide/ixml/ixml-guide/syntax-essentials/strings.md"
section: "ixml-guide"
authority: "guide"
language: "en"
source_repository: "zeyos/guide"
source_path: "docs/ixml/04-syntax-essentials/strings.md"
source_revision: "cce886a8da98cd124ee3644711085bbdcf1a87ce"
---

# String Operations

## `length` / `size`

`length` returns character count (Unicode code points). `size` returns byte count. For ASCII text these are the same; for multibyte UTF-8 they differ.

```xml
<length var="len">iXML</length>
<output>$len</output>
<!-- 4 -->
```

[`length`](https://www.zeyos.com/ixml/ref/length) | [`size`](https://www.zeyos.com/ixml/ref/size)

---

## `char` / `ord`

Convert between characters and UTF-8 code points:

```xml
<output><char>65</char></output>   <!-- A -->
<output><ord>A</ord></output>      <!-- 65 -->
```

[`char`](https://www.zeyos.com/ixml/ref/char) | [`ord`](https://www.zeyos.com/ixml/ref/ord)

---

## `concat` — Append to string

Appends a value to an existing variable. More efficient than `<set var="x">$x$suffix</set>` in loops:

```xml
<set var="name">i</set>
<concat var="name">XML</concat>
<output>$name</output>
<!-- iXML -->
```

[Full reference →](https://www.zeyos.com/ixml/ref/concat)

---

## `tolower` / `toupper`

Case conversion. `toupper` supports modes: `chars` (all), `words` (first letter of each word), `first` (first character only):

```xml
<output><tolower>iXML</tolower></output>
<!-- ixml -->

<output><toupper type="words">bill gates</toupper></output>
<!-- Bill Gates -->
```

[`tolower`](https://www.zeyos.com/ixml/ref/tolower) | [`toupper`](https://www.zeyos.com/ixml/ref/toupper)

---

## `trim` — Strip whitespace

Strips whitespace from both ends (default), left only, or right only:

```xml
<output><trim>     iXML     </trim></output>
<!-- iXML -->
```

[Full reference →](https://www.zeyos.com/ixml/ref/trim)

---

## `pos` — Find position

Finds the position of a search value within a string:

```xml
<output><pos value="X">iXML</pos></output>
<!-- 1 -->
```

[Full reference →](https://www.zeyos.com/ixml/ref/pos)

---

## `substr` — Extract substring

Returns a portion of a string by offset and optional length:

```xml
<output><substr offset="6" length="2">Name: iXML</substr></output>
<!-- iX -->
```

[Full reference →](https://www.zeyos.com/ixml/ref/substr)

---

## `pad` — Pad string

Pads to a given length. Positive length pads right; negative pads left:

```xml
<output><pad length="-10" padding="0">123</pad></output>
<!-- 0000000123 -->
```

[Full reference →](https://www.zeyos.com/ixml/ref/pad)

---

## `match` — Regex match

Performs a global regex match, returning the count and match data:

```xml
<match var="count" var_matches="m" pattern="/ixml/i">My name is iXML!</match>
<output>Found $count match: $m[0][0]</output>
<!-- Found 1 match: iXML -->
```

[Full reference →](https://www.zeyos.com/ixml/ref/match)

---

## `replace` — Search and replace

Supports both literal and regex replacement. Regex mode supports backreferences (`\0` full match, `\1` first capture group):

```xml
<!-- Literal replacement -->
<output>
    <replace value="Bill" replacement="William">Bill Gates</replace>
</output>
<!-- William Gates -->

<!-- Regex with backreferences -->
<output>
    <replace pattern="/(\w+) (\w+)/" replacement="\2, \1">Bill Gates</replace>
</output>
<!-- Gates, Bill -->
```

[Full reference →](https://www.zeyos.com/ixml/ref/replace)

---

## `split` — Split to array

Splits a string into an array by delimiter or regex pattern:

```xml
<split var="names" delimiter=", ">Bill Gates, Steve Jobs</split>
<output>$names[0]</output>
<!-- Bill Gates -->
```

[Full reference →](https://www.zeyos.com/ixml/ref/split)

---

## `convert` — Character encoding

Converts between character encodings (e.g., UTF-8 to ISO-8859-1).

[Full reference →](https://www.zeyos.com/ixml/ref/convert)
