Forums

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

String operations with Usermacros ?

Joerg Bencke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2012

Hi Folks, here is an idea, will it work ?

I always meant to ask, if I can perform string-operations on the page titel in usermacros.

The pagetile says "Introduction (Version 1.0)"

The pagebody says something like

h2. Introduction
This is the introduction to the page .....

Now my question : Could I write a usermacro, that takes "Introduction (Version 1.0)" and does something like

h2. {left($pagetitle,pos($pagetitle,"("))}

So basically to cut off anything from "(" onward ?

Regards, Josch

1 answer

1 accepted

1 vote
Answer accepted
Sandro Herrmann [Communardo]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2012

Yes you can do this .... here is an example usermacro code

## @noparams

#set($charIndexToSlice = $content.title.indexOf("(") )
#set($charIndexToSlice = $charIndexToSlice - 1 )

#if($charIndexToSlice  > -1)
    $content.title.substring(0,$charIndexToSlice )
#end

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events