On 5/19/2012 10:14 PM, Harry wrote:
> Harry wrote...
>>
>> I want to match a name like these,
>> A^Male or A^Female or
>> U^Male or U^Female or
>> D^Male or D^Female or
>>
>> There may be zero, one, or more letters between the first letter [ADU]
>> and the ^ character.
>>
>> I am using the regexp on Oracle 11, with the following expression (not
>> working) ...
>> where ... and REGEXP_LIKE(upper(column_name, '^[ADU](.)*\^FEMALE|MALE
>> $')
>>
>> which picked up name like 'Wu...^Female'.
>>
>> Yeah, I should go to oracle group ... but I hope this regular
>> expression thing
>> is not Oracle specific.
Probably not but does Oracle use BREs or EREs or Perl REs or something else?
Let's assume EREs, then you'd want:
^[ADU].*\^(Female|Male)$
>
> Examples without Oracle ...
> Why would the following name not filtered out?
>
>
> $ echo Wuxyz^Female | tr [[:lower:]] [[:upper:]] |
> egrep '^[ADU](.)*\^FEMALE|MALE$'
> WUXYZ^FEMALE
>
> $ echo Wuxyz^Female | tr [[:lower:]] [[:upper:]] |
> egrep '^[ADU](.)*\^FMALE|MALE$'<-- no E for FEMALE
> WUXYZ^FEMALE
You've got "|MALE$" in the RE so that matches your input which ends in MALE.
Ed.