Oracle regular expression aka regexp, issues with character class

In most programming languages the regular expression pattern to find the digit ‘1’ surrounded by ‘;’ and other digits would be something like


So, the pseudo character class “; or digit” is matched zero or more times, then the digit 1 is matched followed by zero or more “; or digit”s. A few examples:

<property id="foo" value=";1;;;"/>
yet another regexp test with 1;;;;3xxyyzz...
well I think you get the picture with this ;;;;1 shizzle even if it's ;1;2;3; or 123

With Oracle SQL, however, it’s a slightly different story. \d is not supported i.e. not properly recognized as being the character class for digits. However, the character class 0-9 which generally is the equivalent to \d seems to be supported. In Oracle you could therefore use


As far as I can tell this is an undocumented feature. The official Oracle regexp documentation only mentions that it supports the regular POSIX character class [:digit:]. Watch out, the equivalent to \d is the whole expression [:digit:] and not just :digit:. I was first fooled by the extra [] around the character class designator… So, according to the documentation you’d have to use


One thought on “Oracle regular expression aka regexp, issues with character class

  1. I stumbled upon the same issue with d not being honored in a user-defined character class. Tx for confirming my sanity.

Leave a Reply