remove special characters from a string

This question is answered

The users want the item number stripped of all special characters as the search name in the product master.  I have looked on the web, but I have not really found the solution that I am looking for to be able to do this.  Does anyone have a suggestion on how to remove all blanks and special characters?

Thank you

Verified Answer
  • One of my co-workers figured out the solution that works great.

    Static str stripStrings(str _InputString)

    {

       str message;

       message =  System.Text.RegularExpressions.Regex::Replace(_InputString, @"[\W_]", "");

       return message;

    }

All Replies
  • It is possible to do a minor customization, but why do the users want to have the search name stripped? What functionality do they expect further or is it for searching purposes only?

    Shakespeare once quoted: "What's in a name?". My quote: "What's in a number?"

    As you don't give an example I cannot see the need at this moment.

    kind regards,

    André Arnaud de Calavon  |  Microsoft Dynamics AX Solution architect  |  My blog  |  My company

    This post is my own opinion and does not necessarily reflect the opinion or view of my company, Microsoft, both its employees, or other MVPs.

  • The user wants to be able to put dashes or periods in the number, but not have those special characters in the search name.  They have this in the old system and expect it in the new system.  I just need to know how to make them happy.

  • What about modifying NameAlias before a record is inserted into InventTable?

    My blog | PBC

    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • in the worse case , write a new method on the class SysQueryRangeUtil

    see also

    technet.microsoft.com/.../aa569937.aspx

  • One of my co-workers figured out the solution that works great.

    Static str stripStrings(str _InputString)

    {

       str message;

       message =  System.Text.RegularExpressions.Regex::Replace(_InputString, @"[\W_]", "");

       return message;

    }