---
title: "Using Regex Expressions To Select Attachments"
canonical: "https://support.appfire.com/space/TBL/74815060/Using%20Regex%20Expressions%20To%20Select%20Attachments"
format: markdown
---
> Macro (div)
> 
> ### On this page
> 
> > Macro (toc)

# Overview

This page demonstrates how to use the [Attachment Table macro](https://appfire.atlassian.net/wiki/spaces/TBL/pages/74814506), which is part of the [Advanced Tables for Confluence](https://appfire.atlassian.net/wiki/spaces/TBL/overview) add-on, to select attachments based on the Space or attachment name, using a Regex expression.

- Use the special **@self** value for the **spaceRegex** parameter to match on all attachments in the current Space.
- Use **.*png|.*jpg** to match on attachments whose name ends in png or jpg.

# Macro Browser Input

### Select this Macro

|  |  |
| --- | --- |
| *Macro Name* | Attachment table |
| *Macro Syntax* | {attachment-table} |

### Define these Parameters/Values

|  |  |
| --- | --- |
| *Space key or space name regex* | @self |
| Attachment name regex | .*png|.*jpg |

### Screenshot

![image](media://4bfd01a9-3cf0-4ce3-8511-d5bc47ee20cb)


# Wiki Markup Input

```plaintext
{attachment-table:spaceRegex=@self|attachmentRegex=.*png} 
```

> ℹ️ Confluence is more limited on parameter values. In this case, **| **(pipe - used for regex **or**)** **is a reserved character, so it cannot be used.


# Example Result

![image](media://e79e0ef4-b4a6-45be-a6fc-0bf90a25f5eb)

> ✅ **Selecting attachments based on matching on more than one label**
> ✅ 
> ✅ The above example shows how to match on one label. Constructing a regex to match attachments that have 2 or more specific labels is a bit more complicated.
> ✅ 
> ✅ 1. Set the **Label match option** to **all**
> ✅ 2. Use a regex pattern similar to the following using **xxx**, **yyy**, and **zzz** as example labels:
> ✅ 
> ✅ ```
> ✅ 2 labels:  .*(?:.*\b(?:(?:xxx)|(?:yyy))\b.*){2}.*
> ✅ 3 labels:  .*(?:.*\b(?:(?:xxx)|(?:yyy)|(?:zzz))\b.*){3}.*
> ✅ ```


# Other Examples

Visit our [full list of product examples](https://appfire.atlassian.net/wiki/spaces/TBL/pages/74815984) for additional inspiration!