I'm trying to learn regular expressions in Oracle (rather, my first attempt to do anything with RegEx).
What does the symbol ^at the beginning mean ? The documentation mentions
Use the caret and dollar sign to define patterns that match the start or end of a string.
^ defines that start of a string or column 1 of the string.
So, using '^[*est]'as a template, I understand that match anything which has -est as its ending.
However, when I tried,
SQL> select 1 from dual where regexp_like('test','^[*est]');
1
----------
1
SQL> select 1 from dual where regexp_like('best','^[*est]');
no rows selected
SQL> select 1 from dual where regexp_like('fest','^[*est]');
no rows selected
Removal ^however, and get
SQL> select 1 from dual where regexp_like('fest','[*est]');
1
----------
1
SQL> select 1 from dual where regexp_like('best','[*est]');
1
----------
1
SQL> select 1 from dual where regexp_like('test','^[*est]');
1
----------
1
Why is this so? Why in the first case does a match occur for `test ', but not for others?
source
share