Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence automation - how to use match() function

Sebastian Krzewiński
Community Champion
April 22, 2024

Hi!

 

I have a page that contains labels (e.g. label1, label, example, label-something)

I want to use smart value to extract labels that contain "label" in name

 

I tried to use:

  • {{page.labels.name.match("label")}}
  • {{page.labels.name.match("/label/")}}

but for both cases rule return nothing.

 

Can someone help me with this?

 

Regards,

Seba

1 answer

1 accepted

1 vote
Answer accepted
Laurie Sciutti
Community Champion
April 23, 2024

Hey @Sebastian Krzewiński ~ what about:  {{page.labels.name.match("*label*")}}?

Sebastian Krzewiński
Community Champion
April 24, 2024

Hi @Laurie Sciutti 

 

Yours {{page.labels.name.match("*label*")}} will not work. {{page.labels.name}} return a list/array and match() can't work on it.

I figure it out and working formula looks like below:

{{#page.labels}}{{#if(equals(name.match(".*(label).*"), "label"))}} {{name}} - ({{id}}) {{/}};{{/}}

In loop I'm checking each label name and check if label name contain label. If yes, I'm displaying name and id.

 

Thanks for your reply and help!

 

Regards,

Seba

Like # people like this
Laurie Sciutti
Community Champion
April 24, 2024

Wow.  Nice job, @Sebastian Krzewiński !

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events