Topic
  • 9 replies
  • Latest Post - ‏2015-05-27T07:06:31Z by CognosAdmin
SystemAdmin
SystemAdmin
1959 Posts

Pinned topic substitute macro pattern_string

‏2013-03-20T18:16:41Z |
the language describing the pattern_string hints at regex-like functionality:

Example 1

#sq ( substitute ( '^cn=', '***', 'cn=help' ) )#
Result: '***help'

however, whenever i try to use a regex to find a string to substitute i get this error:
QE-DEF-0396 The search_pattern '{my pattern}' argument to macro function 'substitute' is not valid

i'm trying to find the first instance of a square-bracketed string to rewrite a MUN. i'm trying the following:

#substitute('^[*]', 'my new cube', prompt('pMUN','mun'))#

any ideas why this isn't working?
Updated on 2013-04-03T20:21:24Z at 2013-04-03T20:21:24Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1959 Posts

    Re: substitute macro pattern_string

    ‏2013-03-20T18:21:26Z  
    correction to my substitute call to correct html formatting:
    #substitute('^\\[*\\]', '[my new cube]', prompt('pMUN','mun'))#
  • DanielWagemann
    DanielWagemann
    850 Posts

    Re: substitute macro pattern_string

    ‏2013-03-20T18:51:06Z  
    correction to my substitute call to correct html formatting:
    #substitute('^\\[*\\]', '[my new cube]', prompt('pMUN','mun'))#
    Have a look at the end of the following post to see if it helps.

    http://www.ibm.com/developerworks/forums/thread.jspa?threadID=473178&tstart=30
  • SystemAdmin
    SystemAdmin
    1959 Posts

    Re: substitute macro pattern_string

    ‏2013-03-20T19:24:03Z  
    Have a look at the end of the following post to see if it helps.

    http://www.ibm.com/developerworks/forums/thread.jspa?threadID=473178&tstart=30
    thanks Daniel, i have managed to get the substitute working when the search_pattern contains a known name. but the fact that you can use "^" and you have to escape special characters implies that the search_pattern could be a regex. i'm just wondering how to format the regex properly, or if it truly is a regex at all:

    to recap:
    search_pattern works: \[somecube\]
    search_pattern fails: \[*\]

    any thoughts?
  • DanielWagemann
    DanielWagemann
    850 Posts

    Re: substitute macro pattern_string

    ‏2013-03-21T15:00:43Z  
    thanks Daniel, i have managed to get the substitute working when the search_pattern contains a known name. but the fact that you can use "^" and you have to escape special characters implies that the search_pattern could be a regex. i'm just wondering how to format the regex properly, or if it truly is a regex at all:

    to recap:
    search_pattern works: \[somecube\]
    search_pattern fails: \[*\]

    any thoughts?
    I am not sure that it is true regex, maybe a loose interpertation. I am going to look into this a bit further. This may take a bit of time but I will get back to you either way once I have more.

    I am very interested in the wildcard replace of an unknown with a know as it would make double substitutions obsolete.
  • DanielWagemann
    DanielWagemann
    850 Posts

    Re: substitute macro pattern_string

    ‏2013-03-26T19:31:25Z  
    I am not sure that it is true regex, maybe a loose interpertation. I am going to look into this a bit further. This may take a bit of time but I will get back to you either way once I have more.

    I am very interested in the wildcard replace of an unknown with a know as it would make double substitutions obsolete.
    I have not forgotten about this. The fellow I speak to about these things is currently out.
  • DanielWagemann
    DanielWagemann
    850 Posts

    Re: substitute macro pattern_string

    ‏2013-04-01T15:13:57Z  
    I have not forgotten about this. The fellow I speak to about these things is currently out.
    Sorry for the delay, wildcard replaces are currently not available within the macro expression. This would be considered a product enhancement.
  • SystemAdmin
    SystemAdmin
    1959 Posts

    Re: substitute macro pattern_string

    ‏2013-04-03T20:21:24Z  
    thanks for checking. seems like it would be a useful enhancement, so maybe we'll see it in a future release.
  • CognosAdmin
    CognosAdmin
    21 Posts

    Re: substitute macro pattern_string

    ‏2015-05-27T07:06:20Z  

    Hi,

    Try this link with simple steps

    http://www.cognosasksumeet.blogspot.in/search/label/Cognos%3A%20Using%20optional%20parameter%20in%20a%20Data%20item%20with%20macro

     

    Thanks

     

  • CognosAdmin
    CognosAdmin
    21 Posts

    Re: substitute macro pattern_string

    ‏2015-05-27T07:06:31Z  
    correction to my substitute call to correct html formatting:
    #substitute('^\\[*\\]', '[my new cube]', prompt('pMUN','mun'))#

    Hi,

    Try this link with simple steps

    http://www.cognosasksumeet.blogspot.in/search/label/Cognos%3A%20Using%20optional%20parameter%20in%20a%20Data%20item%20with%20macro

     

    Thanks