Skip to main content

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 | 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 | 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 →


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 | toupper


trim — Strip whitespace

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

XML
<output><trim> iXML </trim></output>
<!-- iXML -->

Full reference →


pos — Find position

Finds the position of a search value within a string:

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

Full reference →


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 →


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 →


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 →


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 →


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 →


convert — Character encoding

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

Full reference →