web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Replacing characters in string

(0) ShareShare
ReportReport
Posted on by 45

Hi,

 I had a small question.

Could any one solve me that how can i change string.

for example there is a string ABC-#### now i need to get output as 1111  in place of #'s.

*This post is locked for comments

I have the same question (0)
  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Can you provide some more information as the string you provided seems to be some numbersequenceId.

    Thanks,
    Chaitanya Golla

  • Murali Ravikanti Profile Picture
    45 on at

    No it  not a numbersequenceId it is just a small job i need to display the string ABC-#### as 1111 so i need to show output. In out i need not to show ABC-

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    You need to use strReplace function as below.

    Refer link: msdn.microsoft.com/.../global.strreplace.aspx

    static void AxC(Args _args)

    {

      str s;

      s = strReplace("ABC-####", "#", "1");

      info(strFmt("%1", s));

    }

    Thanks,

    Chaitanya Golla

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    Hi Murali,

    If you actually want to replace the # characters from the string with a single character you can do that as explained by Chaitanya above.

    If you just want to get the string after the prefix (ABC-) you can use substr function. Something like this:

    str newVal = subStr( yourString, 5, strlen(yourString));


  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    str myInputStr = 'ABC-####';
    str myOutputStr = strDel(myInputStr, 5, 4);
    info(myOutputStr);
    info(myOutputStr + '1111');

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans