Pattern matching and wildcards

Have you ever found yourself trying to do things depending on some text in the name or the description of a card? For example, moving cards between lists or assigning cards to certain board members when the cards match against a specific text or number. Automations support patterns and wildcards to perform such tasks. 

Using wildcards in automation triggers

In an automation, the wildcard is the special sequence that matches any text in the card name or description. 

Automation supports several types of wildcards: 

  • {*}: this wildcard will match any text with blank spaces. Typically, it is used to match the text at the end of a card name or description.

  • {* }: this wildcard will match a text until a blank space or the end of the text. Typically, it is used to match the text at the beginning/in the middle of a card name or description. When using this wildcard, make sure that you include a blank space in between the asterisk and the closing bracket.

  • {?}: this wildcard will match the minimum amount of text.

The pattern is the matched text. Patterns can get very complex, with multiple wildcards in one pattern.

Automation patterns and wildcards are most frequently used in trigger conditions—clauses that can be applied to a trigger so that it only fires for cards with certain features. 

Example (automation with a trigger condition and pattern):

when a card containing "urgent" is moved to list "Assigned tasks", copy the card to "My urgent tasks" on board "My main board" and link the cards together

In this automation, the clause containing "urgent" is the trigger condition and "urgent" is the pattern.


Example (automation with a trigger condition, pattern, and a wildcard)

When a card with a name ending with "invoice #{*}" is added to "Inbox", add the "Invoice" label to the card and post comment "@board Invoice number {wildcard1} is in this card!"

This automation also includes the {*} wildcard that will match any text in the card name, including blank spaces. For instance, the automation will trigger for a card named "Attached invoice #0001"When the automation is executed, it will post a comment "@board Invoice number 0001 has arrived!"

A card name or description must match the specified pattern for the trigger condition to be met. For instance, if the pattern is "invoice - {*}", only cards containing the "invoice - " in the name or description will be matched.

Also, pay attention to the {wildcard1} variable. This variable takes the value of the first (and in this case the only) wildcard in the condition pattern. In the given example, it will take the value 0001.

Note: You can also use additional wildcard variables instead of the default ones ({wildcard1}{wildcard2}, and others) to match against a particular user in automations with certain triggers.


Example (a pattern and a wildcard variable)

If the text is Monday - Tuesday - Wednesday, and the pattern is {*} - {*}, then:

  • {wildcard1} will be Monday - Tuesday

  • {wildcard2} will be Wednesday

To match "Monday" in this example, the {?} wildcard could be used. For example with the same text as above, and a pattern {?} - {*}:

  • {wildcard1} will be Monday

  • {wildcard2} will be Tuesday - Wednesday


A more complex example

when the name of a card contains "HOT {* } in Automation: {*}", send an email notification to "user@gmail.com" with subject "A bug has been detected!" and message "Ticket: {wildcard1}\n\nIssue: {wildcard2}"

Note: The \n\n notation breaks the text into a separate line, following the markdown formatting used in Trello.

In this example, when a card named "HOT 54836 in Automation: Slack notifications aren't working" is added to the board, Automation will send the following email to user@gmail.com:

screenshot_ABugHasBeenDetected

Using wildcards in other parts of automations

You can use wildcards not just to match the text in the name or description of a card, but also in the names of pretty much every Trello element. For example, you can add wildcards to the member, checklist, list, and board information. 

Example

when a card is moved to list "Week {*}" by anyone, post comment "Scheduled for week {wildcard1} on {date} by {username}."

This automation will trigger for any list which name starts with "Week". Check more information on this video “Automation: Adding a wildcard to an automation

Field based wildcard references

Automation allows you to reference wildcards defined in different parts of the automation, by the field they were matched in. 

For example, an automation like when a checklist item starting with "{*} - {*}" is checked in a card named "{*} for project {*}/{*}" in list "To Do {*}" contains multiple wildcards, in different parts of the automation. 

These can be referenced like so:

  • Card name: {cardnamewildcard1}{cardnamewildcard2}, etc...

  • Checklist item name: {itemwildcard1}{itemwildcard2}, etc...

  • List name: {listwildcard1}{listwildcard2}, etc...

Other fields

These fields all follow the same pattern as the three examples above, with a suffix to indicate which match (if there are multiple) to reference.

Field

Wildcard

Checklist name

checklistwildcard1

Card description

carddescriptionwildcard1

Comment

commentwildcard1

Label name

labelwildcard1

Attachment name

attachmentwildcard1

Additional Help