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
AUG Leaders

Atlassian Community Events