---
title: "Transforming directory field data with regex and Liquid"
slug: "transforming-directory-field-data-using-liquid-and-regex"
description: "Reformat directory data before it appears in Opensense signatures, with regex transforms or Liquid: phone formats, name order, case, and characters."
updated: 2026-03-18T19:27:03.000Z
canonical: "https://help.opensense.com/docs/transforming-directory-field-data-using-liquid-and-regex"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://help.opensense.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Transforming directory field data with regex and Liquid

## Overview

Field transformations reformat data from your directory before it appears in email signatures, without changing anything in your identity provider. This is useful when your directory stores data in a format that differs from how it should be displayed, such as unformatted phone numbers, or names stored in last-first order.

:::note[Directory data only]
Transformations apply to directory-synced data only. They don't affect values entered manually through custom compose fields.
:::

## What you can do

### Phone number formatting

Each input example is shown with its output format:

<dl class="kb-insights-summary">
  <div><dt><code>6043334567</code></dt><dd><code>(604) 333-4567</code></dd></div>
  <div><dt><code>604-333-4567</code></dt><dd><code>604.333.4567</code></dd></div>
  <div><dt><code>6043334567 x1234</code> (with extension)</dt><dd><code>604.333.4567</code></dd></div>
  <div><dt>Any format stored in AD</dt><dd><code>604.333.4567</code> or <code>604-333-4567</code></dd></div>
</dl>

### Text formatting

<div class="kb-deployment-compare kb-deployment-compare--plain">
  <div class="kb-deployment-compare__viewport" role="region" aria-label="Text formatting examples" tabindex="0">
    <table>
      <colgroup><col class="kb-deployment-compare__feature-col"></colgroup>
      <thead>
        <tr>
          <th scope="col">Transformation</th>
          <th scope="col"><span class="kb-deployment-compare__method">Input example</span></th>
          <th scope="col"><span class="kb-deployment-compare__method">Output example</span></th>
        </tr>
      </thead>
      <tbody>
        <tr><th scope="row">Flip name order</th><td><code>Doe, Jane</code></td><td><code>Jane Doe</code></td></tr>
        <tr><th scope="row">All uppercase</th><td><code>jane doe</code></td><td><code>JANE DOE</code></td></tr>
        <tr><th scope="row">All lowercase</th><td><code>JANE DOE</code></td><td><code>jane doe</code></td></tr>
        <tr><th scope="row">Remove specific characters</th><td><code>Director - Sales</code></td><td><code>Director</code></td></tr>
        <tr><th scope="row">Trim whitespace</th><td><code>[space] Jane Doe</code></td><td><code>Jane Doe</code></td></tr>
      </tbody>
    </table>
  </div>
</div>

## Two approaches

You can configure transformations with either **regex transforms** or **Liquid**, depending on what you need.

### Regex transforms

Regex transforms are configured in the **Transforms** panel under each field mapping. Steps run in sequence, and each step receives the output of the previous one. Built-in keywords handle common operations, without your having to write custom patterns:

<dl class="kb-insights-summary">
  <div><dt><code>formatPhone</code></dt><dd>Normalizes digits into a standard phone format.</dd></div>
  <div><dt><code>flipNameComma</code></dt><dd>Converts "Last, First" to "First Last".</dd></div>
  <div><dt><code>toUpperCase</code>, <code>toLowerCase</code></dt><dd>Changes the case.</dd></div>
  <div><dt><code>trim</code></dt><dd>Removes leading and trailing whitespace.</dd></div>
  <div><dt><code>space</code></dt><dd>Inserts or matches a literal space.</dd></div>
</dl>

### Liquid

Liquid is entered directly in the **Source** field. It handles scenarios that regex transforms aren't suited for, such as removing or replacing specific characters, conditional logic, fallback values when a field is empty, or custom string manipulation beyond what the built-in keywords support.

## Which approach to use

<div class="kb-deployment-compare kb-deployment-compare--plain">
  <div class="kb-deployment-compare__viewport" role="region" aria-label="Which approach to use for each scenario" tabindex="0">
    <table>
      <colgroup><col class="kb-deployment-compare__feature-col"></colgroup>
      <thead>
        <tr>
          <th scope="col">Scenario</th>
          <th scope="col"><span class="kb-deployment-compare__method">Use</span></th>
        </tr>
      </thead>
      <tbody>
        <tr><th scope="row">Phone number formatting (any common format)</th><td>Regex transforms (<code>formatPhone</code>)</td></tr>
        <tr><th scope="row">Name order (Last, First to First Last)</th><td>Regex transforms (<code>flipNameComma</code>)</td></tr>
        <tr><th scope="row">Case standardization</th><td>Regex transforms (<code>toUpperCase</code> or <code>toLowerCase</code>)</td></tr>
        <tr><th scope="row">Trimming leading or trailing whitespace</th><td>Regex transforms (<code>trim</code>)</td></tr>
        <tr><th scope="row">Removing or replacing specific characters</th><td>Liquid</td></tr>
        <tr><th scope="row">Conditional output or fallback values</th><td>Liquid</td></tr>
        <tr><th scope="row">Complex multi-step logic not covered by built-in keywords</th><td>Liquid</td></tr>
      </tbody>
    </table>
  </div>
</div>


## What's next

- [Showing signature elements based on a field value (Liquid templates)](https://help.opensense.com/docs/display-signature-elements-based-on-field-value-liquid-templates-only)
- [How often Opensense syncs user data](https://help.opensense.com/docs/automatic-sync-frequency)

For further help, contact Opensense Support at [help@opensense.com](mailto:help@opensense.com).
