POSITION_REGEX
POSITION_REGEX is a function in SQL designed to return the position of the first occurrence of a regular expression in a particular string.
Example
SELECT POSITION_REGEX('C' IN 'Oracle' ) FROM DUAL;
Output
4
Explanation
In the above example, POSITION_REGEX
function finds the position of the first occurrence of ‘C’ in the string ‘Oracle’. The function returns the position as an integer value, which in this case is 4.
Example
SELECT POSITION_REGEX('W' IN 'Hello World' SIMILAR TO '%');
Output
7
Explanation
The POSITION_REGEX() function in the example checks for the position of the character ‘W’ in the string ‘Hello World’. It’s similar to to ’%’ which signifies any string sequence. The returned value is ‘7’, indicating that the ‘W’ is at the seventh position in the string ‘Hello World’.