The Regular Expression Function REGEXP_LIKE is used in Oracle queries, and the Like operator in Oracle uses
The Regular Expression Function REGEXP_LIKE is used in Oracle queries, and the Like operator in Oracle uses
The Like operators in Oracle use '_' and '%' As wildcards, just Like this:
That is, all rows with the 2nd letters a in the name column of the test_like table are matched. However, note that Oracle matches the time zone in Case sensitivity. That is to say, the line name = 'saas 'cannot be queried during the above query.
The regular expression function provided by Oracle10g can solve this problem well. Of course, this is not the only advantage of using a regular expression function. In fact, it is much more powerful than the Like operator.
The syntax of regular expressions is unnecessary. Currently, most languages support regular expressions.
The following describes how to use the regular expression function REGEXP_LIKE in Oracle:
For example:
The preceding SQL statement matches the name column in The test_reg table with two consecutive characters 'A' (Case Insensitive), such as name = 'saas '. In addition, we also use the back reference syntax in the Regular Expression -- \ n to repeat the content of the last match n times. Here () \ 1 indicates matching two consecutive characters 'A '.
Note that the double brackets must be used for subsequent references. Otherwise, the following result is displayed:
Finally, do not confuse the wildcards of the like operator with the regular expression syntax, that is, do not use wildcards in the LIKE operator in a regular expression. If this is done, unknown results will be obtained ,, because '_' and '%' are matched by regular expressions as common characters.
For example, if the following SQL statement is used to obtain the record name = 'saas ', the actual query result is null.
Actually use:
For more information about Oracle, see the Oracle topic page? Tid = 12