Reputation: 1782
I have a query which I was using in an Access database to match a field. The rows I wish to retrieve have a field which contains a sequence of characters in two possible forms (case-insensitive):
*PO12345
, 5 digits preceded by *PO
, or PO12345
, 5 digits preceded by PO
.In Access I achieved this with:
WHERE MyField LIKE '*PO#####*'
I have tried to replicate the query for use in an Oracle database:
WHERE REGEXP_LIKE(MyField, '/\*+PO[\d]{5}/i')
However, it doesn't return anything. I have tinkered with the Regex slightly, such as placing brackets around PO
, but to no avail. To my knowledge what I have written is correct.
Upvotes: 0
Views: 277
Reputation:
Your regex \*+PO[\d]{5}
is wrong. There shouldn't be +
after \*
as it's optional.
Using ?
like this /\*?PO\d{5}/i
solves the problem.
Use i
(case insensitive) as parameter like this: REGEXP_LIKE (MyField, '^\*?PO\d{5}$', 'i');
Read REGEXP_LIKE documentation.
Upvotes: 4