Replace String Method The Replace String method uses the regular expression

Replace string method the replace string method uses

This preview shows page 99 - 102 out of 334 pages.

Replace String Method The Replace String method uses the regular expression that you define in the pattern argument to search a string. If it finds a match, then it replaces the string it finds with the string that you define in the replexp argument. If you use T eScript code, and if this method replaces a string, then it sets the appropriate static properties for the regular expression object. These properties provide more information about the replacements. For more information, see “Using the Get Regular Expression from String Method with the T eScript Engine” on page 202 . Format stringVar .replace( pattern , replexp )
Image of page 99
Siebel eScript Language Reference Version 8.1, Rev. A Methods Reference String Methods 100 Table 41 describes the arguments for the Replace String method. Special Characters You Can Use in a Replacement Expression Table 42 describes the special characters that you can use in a replacement expression. Example The following example includes the Replace String method: var rtn; var str = "one two three two one"; var pat = /(two)/g; // rtn == "one zzz three zzz one" rtn = str.replace(pat, "zzz"); // rtn == "one twozzz three twozzz one"; rtn = str.replace(pat, "$1zzz"); Table 41. Arguments for the Replace String Method Argument Description pattern Regular expression that this method finds in a string. replexp A replacement expression, which can be one of the following items: String String that includes regular expression elements Function Table 42. Special Characters You Can Use in a Replacement Expression Character Description $1, $2 … $9 The text that the regular expression matches. This text resides in a set of parentheses in the string. For example, $1 replaces the text that the Replace String method matches in the first regular expression it encounters that resides in a set of parentheses. $+ Same as the $1, $2 … $9 characters, except with the $+ character the replacement occurs in the regular expression that resides in the last set of parentheses. $& The text that a regular expression matches. $` The text to the left of the text that a regular expression matches. $' The text to the right of the text that a regular expression matches. \$ The dollar sign character.
Image of page 100
Methods Reference String Methods Siebel eScript Language Reference Version 8.1, Rev. A 101 // rtn == "one 5 three 5 one" rtn = str.replace(pat, five()); // rtn == "one twotwo three twotwo one"; rtn = str.replace(pat, "$&$&”); function five() { return 5; } Search String for Substring Method The Search String for Substring method searches the stringVar variable for the entire string that you specify in the substring argument. It returns the position of the first occurrence of this string. If any of the following situations is true, then it returns a value of negative 1: It does not find the value that you specify in the substring argument.
Image of page 101
Image of page 102

You've reached the end of your free preview.

Want to read all 334 pages?

  • Summer '16
  • Oracle
  • Type system, Siebel, Siebel eScript

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes