Thursday, May 24, 2012

TextBuffer Class to replace the special characters in string.

TextBuffer class can be used to replace the text/characters in the string.
Usually its used to replace the special character with escape sequence so that string(data with special character) can be inserted into the database.

Following job illustrates how to achieve this.

static void Dev_ReplaceTxt(Args _args)
{

TextBuffer buffer = new TextBuffer();
Str message;
;

message = " hi hello's how r u's ";
message += " How r u doing's wujer's * ? ' what ur mot's anbej's";

buffer.setText(message);
buffer.replace("[*?']","\\'"); // replace special character with escape sequence
info(buffer.getText());

}

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...