I need to build a query in PostgreSQL and am required to find all text entries that contain a 6 digit number (e.g. 000999, 019290, 998981, 234567, etc). The problem is that the number is not necessary at the begining of the string or at its end.
I tried and didn't 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 skills required. Any idea what regexp could be used or other tricks that elude me at the moment?
EDIT
Input samples:
aa 0011527 /CASA-> should return NOTHINGaa 001152/CASA-> should return001152aa001152/CASA-> should return001152aa0011527/CASA-> should return NOTHINGaa001152 /CASA-> should return001152
I tried your solution, but didn't work. I added some samples in my question. – CristisS Jan 24 '13 at 14:20