Skip to content
Advertisement

Oracle/SQL: Regexp Similar to LIKE-% but wildcard mandatory (not optional)

I’m in Oracle 10, and need an equivalent of

where col like 'str%'

but where the %-part is not optional. The result of str is not allowed.

Is the following correct?

WHERE REGEXP_LIKE (col, '^str(*)+');

https://www.techonthenet.com/oracle/regexp_like.php

Reason: 1) Match any character, (*) 2) Occurrence must be at least 1, +

Advertisement

Answer

You can use _:

where col like 'str_%'

This requires at least one character after the 'str'.

If you want regular expressions, the simplest is probably:

WHERE REGEXP_LIKE(col, '^str.');
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement