---
title: "Extract values from page titles using regex"
canonical: "https://support.appfire.com/space/REPS/472916767/Extract%20values%20from%20page%20titles%20using%20regex"
format: markdown
---
> Macro (aura-html)

## Scenario

You can extract certain values from page titles and then show them in different columns by manipulating Reporting outputs using [regular expressions](https://www.regular-expressions.info/) (regex).

In this scenario, we are going to use Page Supplier, Text Supplier, and Match Supplier keys and regular expressions (regex) to extract country name, code, and phone code from page titles.

In this example, the page titles have a format of `<Country Name> (<Country Code-Phone Code>).`

![image](media://8843802e-3ae9-4e38-a2f2-7875772f12ba)

We will separate the parts of the titles by using regex and show them in different columns.

## Result

![image](media://73bb9128-0a19-4256-9113-dd668ed55413)

 

## Recipe

| Apps | Reporting for Confluence Data Center |
| --- | --- |
| Level | Intermediate |
| Estimated time | 20 minutes |
| Macros | Local Reporter, Report Column, Report Info, Report Table |
| Suppliers | Match Supplier, Page Supplier, Text Supplier |

## Storage format

You can copy and paste this code into the [Confluence Source Editor](https://appfire.atlassian.net/wiki/spaces/REPS/pages/472907841):

```
<p class="auto-cursor-target">
  <br />
</p>
<ac:structured-macro ac:macro-id="a5cba1e5-c4b8-4862-b166-2647928ce198" ac:name="report-table" ac:schema-version="1">
  <ac:rich-text-body>
    <p class="auto-cursor-target">
      <br />
    </p>
    <ac:structured-macro ac:macro-id="437878cf-aa05-4e77-b9e6-61a5f964169d" ac:name="local-reporter" ac:schema-version="1">
      <ac:parameter ac:name="">page:children</ac:parameter>
      <ac:rich-text-body>
        <p>
          <br />
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br />
    </p>
    <ac:structured-macro ac:macro-id="b58a39ec-31bc-4720-a16d-73fb73061669" ac:name="report-column" ac:schema-version="1">
      <ac:parameter ac:name="title">Page Title</ac:parameter>
      <ac:rich-text-body>
        <p>
          <ac:structured-macro ac:macro-id="76f9c3b0-1b6c-4815-a217-944a20c1e174" ac:name="report-info" ac:schema-version="1">
            <ac:parameter ac:name="link">true</ac:parameter>
            <ac:parameter ac:name="">page:title</ac:parameter>
          </ac:structured-macro>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br />
    </p>
    <ac:structured-macro ac:macro-id="b6dc99fc-61ae-4f8f-8e3f-1138b39700f6" ac:name="report-column" ac:schema-version="1">
      <ac:parameter ac:name="title">Country</ac:parameter>
      <ac:rich-text-body>
        <p>
          <ac:structured-macro ac:macro-id="5edbc5e9-2608-47a5-917c-a1d86f7e96c8" ac:name="report-info" ac:schema-version="1">
            <ac:parameter ac:name="">page:title&gt;match "(.*?)\\((.*?)-(.*?)\\)"&gt;group 1</ac:parameter>
          </ac:structured-macro>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br />
    </p>
    <ac:structured-macro ac:macro-id="916564d5-beef-4522-8178-bdcca66f1d55" ac:name="report-column" ac:schema-version="1">
      <ac:parameter ac:name="title">Country Code</ac:parameter>
      <ac:rich-text-body>
        <p class="auto-cursor-target">
          <ac:structured-macro ac:macro-id="3a8d45d9-23cd-4eb1-ac04-5e1a264eda5f" ac:name="report-info" ac:schema-version="1">
            <ac:parameter ac:name="">page:title&gt;match "(.*?)\\((.*?)-(.*?)\\)"&gt;group 2</ac:parameter>
          </ac:structured-macro>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br />
    </p>
    <ac:structured-macro ac:macro-id="e31cf1e5-4f88-4c0d-884d-cd71e3ae4235" ac:name="report-column" ac:schema-version="1">
      <ac:parameter ac:name="title">Phone Code</ac:parameter>
      <ac:rich-text-body>
        <p class="auto-cursor-target">
          <ac:structured-macro ac:macro-id="17eae913-5333-444e-882d-97f361108bfd" ac:name="report-info" ac:schema-version="1">
            <ac:parameter ac:name="">page:title&gt;match "(.*?)\\((.*?)-(.*?)\\)"&gt;group 3</ac:parameter>
          </ac:structured-macro>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br />
    </p>
  </ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
  <br />
</p>

```

## Macro structure

You can recreate the example in the editor view:

![image](media://5a11fee5-93e3-4481-968b-47141d68de90)

## Steps

1. Add a Report Table macro and within it, add a Local Reporter macro with the **Key** parameter set to `page:children`.
2. Under the Local Reporter, add Report Column macro with **Title** set to `Page Title`.
3. Within the *Page Title* Report Column macro, add a Report Info macro with **Key **set** **to `page:title` and **Link to item** selected.
4. Under the *Page Title* Report Column macro, add another Report Column macro with **Title** set to `Country`.
5. Within the *Country *Report Column macro, add a Report Info macro with **Key **set** **to `page:title>match "(.*?)\\((.*?)-(.*?)\\)">group 1`.
6. Under the *Country* Report Column macro, add another Report Column macro with **Title** set to `Country Code`.
7. Within the *Country Code *Report Column macro, add a Report Info macro with **Key **set** **to `page:title>match "(.*?)\\((.*?)-(.*?)\\)">group 2`.
8. Under the *Country * Report Column macro, add another Report Column macro with **Title** set to `Phone Code`.
9. Within the *Phone Code *Report Column macro, add a Report Info macro with **Key **set** **to `age:title>match "(.*?)\\((.*?)-(.*?)\\)">group 3`.

## Regex explanation

The `(.*?)\\((.*?)-(.*?)\\)` regex is used to group page titles output into three groups:

|  |
| --- |
| **Group 1: **`(.*?)`<br>To select all values until the opening bracket (`(`) character.<br>**Skipped: **`\\(`<br>The opening bracket (`(`) character is excluded from the groups. |
| **Group 2: **`(.*?)`<br>To select all characters after the opening bracket and before the first dash (`-`) character.<br>**Skipped: **`-`<br>The dash (`-`) character is excluded from the groups. |
| **Group 3: **`(.*?)`<br>To select all values after the dash (`-`) character and before the closing bracket (`)`).<br>**Skipped: **`\\)`<br>The closing bracket (`)`) character is excluded from the groups |