I need to create a query to the PostgreSQL, and I need to find all text entries that contain the 6-digit number (eg 000999, 019290, 998981, 234567etc.). The problem is that the number is not necessarily at the beginning of the line or at the end of it.
I tried and did not work:
[0-9]{6} - returns part of a number with more than 6 digits(?:(?<!\d)\d{6}(?!\d)) - postgresql does not know about lookbehind[^0-9][0-9]{6}[^0-9] and variations on it, but to no avail.
Building my own Perl / C function is not really an option, as I do not have the necessary skills. Any idea that regexp can be used or other tricks that are eluding me at the moment?
EDIT
Input samples:
aa 0011527 /CASA → must return NOTHINGaa 001152/CASA → must return 001152aa001152/CASA → must return 001152aa0011527/CASA → must return NOTHINGaa001152 /CASA → must return 001152