Thursday, Oct. 19, 2017

Special / Junk character removal from data

Written By:

|

March 15, 2012

|

Posted In:

Many times when you migrate data from other systems to Siebel, it contains certain special or junk characters that can lead to a lot of problems. So its better to replace those characters with other more acceptable characters.

Best way to search and replace those characters is by using RegExp() object used in a business service. If you don’t know how to create a business service, please follow the below link:

Creating Client Side Business Service

I am just going to explain you the use of RegExp() object. It has three methods to work with(that works with both Siebel engines):

—  RegExp compile() Method

—  RegExp exec() Method

—  RegExp test() Method

Most important one is exec() method: This method returns an array of strings found with the regular expression specified, along with their property sets. It  returns null if no match is found.

Syntax:

StringVar1 = new RegExp(/<pattern>/<arguments>);

Pattern can have :

*    : zero or more characters
+   :  one or more characters
?    :  zero or one characters
.    :  Any character except newline
\    Escape character to match any special character (For e.g. * or +)
\s   whitespace character (tab, space and newline)
\d   any digit

 Arguments can have :

g    global (all occurrences)
m   multiline
i    case insensitive
Combinations of above three

For e.g.

var String1 = “Experts from web”;

var chk = new RegExp(/w+b/m);

match = chk.exec(String1)            //Returns “web”

var chk2 = new RegExp(/*w+b/m);

match2 = chk2.exec(String1)       //Returns “Experts from web”

Another useful method is String replace() Method: This method searches a string using the regular expression pattern. If a match is found, it is replaced by the substring specified.

Syntax:

stringVar.replace(pattern, Strreplace)

Pattern : Regular expression pattern to find or match in string.

Strreplace : Replacement expression which may be a string, a string with regular expression elements, or a function.



Share This Article

About Author

Rohit

Siebel Technical Consultant

  • Ted

    Thanks looking for the same