REGEXP_LIKE behaviour

Hi All,
I need to return list of all post codes that does match with my formats like ("A9 9AA","A99 9AA")
i written the query like below but i am not getting correct result some of records are not displaying in the result set can you please help on this.

please confirm whether the character(|) used correctly or not,to combine these two different formats.

select cli,post_code
from address_v6
where
regexp_like(post_code,'^[A-Z]{1}[0-9]{1} [0-9]{1}[A-Z]{2}$
|^[A-Z]{1}[0-9]{2} [0-9]{1}[A-Z]{2}$')

 
Not really a PL/SQL Developer question, but I'll bite...

As long as I remove the line-break between $ and |, the regexp you give matches the two formats you specified ("A9 9AA","A99 9AA"). That said, the following regexp does as well and is significantly simpler: ^[A-Z][0-9]{1,2} [0-9][A-Z]{2}$

However, according to wikipedia, you should be using: ^[A-Z]{1,2}[0-9]{1,2}[A-Z]? [0-9][A-Z]{2}$

Disclaimer: I don't know anything about post codes. But I do know regular expressions.
 
Back
Top