The following example examines the string, looking for two or more spaces. REGEXP_REPLACE(country_name, '(.)', '\1 ') "REGEXP_REPLACE" Oracle puts a space after each non-null character in the string. The following example examines country_name. Oracle reformats this pattern with ( xxx) xxx- xxxx. The following example examines phone_number, looking for the pattern xxx. REGEXP_INSTR, REGEXP_SUBSTR, and REGEXP_LIKE Condition The source string is treated as a single line. The default case sensitivity is determined by the value of the NLS_SORT parameter.Ī period (.) does not match the newline character. If you specify a character other than those shown above, then Oracle returns an error. For example, if you specify 'ic', then Oracle uses case-sensitive matching. If you specify multiple contradictory values, Oracle uses the last value. By default, whitespace characters match themselves. If you omit this parameter, Oracle treats the source string as a single line. Oracle interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. 'm' treats the source string as multiple lines. If you omit this parameter, the period does not match the newline character. 'n' allows the period (.), which is the match-any-character character, to match the newline character. You can specify one or more of the following values for match_parameter: This argument affects only the matching process and has no effect on replace_string. Match_parameter is a text literal that lets you change the default matching behavior of the function. If you specify a positive integer n, then Oracle replaces the nth occurrence. If you specify 0, then Oracle replaces all occurrences of the match. Occurrence is a nonnegative integer indicating the occurrence of the replace operation: The default is 1, meaning that Oracle begins the search at the first character of source_char. Position is a positive integer indicating the character of source_char where Oracle should begin the search. For more information on backreference expressions, please refer to the notes to "Oracle Regular Expression Support", Table C-1. If n is the backslash character in replace_string, then you must precede it with the escape character ( \\). The replace_string can contain up to 500 backreferences to subexpressions in the form \n, where n is a number from 1 to 9. If replace_string is a CLOB or NCLOB, then Oracle truncates replace_string to 32K. Replace_string can be of any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. For a listing of the operators you can specify in pattern, please refer to Appendix C, "Oracle Regular Expression Support". If the datatype of pattern is different from the datatype of source_char, Oracle Database converts pattern to the datatype of source_char. It is usually a text literal and can be of any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. It is commonly a character column and can be of any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB or NCLOB. Source_char is a character expression that serves as the search value. For more information, please refer to Appendix C, "Oracle Regular Expression Support". This function complies with the POSIX regular expression standard and the Unicode Regular Expression Guidelines. The function returns VARCHAR2 if the first argument is not a LOB and returns CLOB if the first argument is a LOB. The string returned is in the same character set as source_char. By default, the function returns source_char with every occurrence of the regular expression pattern replaced with replace_string. REGEXP_REPLACE extends the functionality of the REPLACE function by letting you search a string for a regular expression pattern. Description of the illustration regexp_replace.gif
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |