Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

need help on regular expression

10 views
Skip to first unread message

Harry

unread,
May 19, 2012, 10:01:26 PM5/19/12
to
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.

TIA

Harry

unread,
May 19, 2012, 11:14:41 PM5/19/12
to
Harry wrote...
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


Ed Morton

unread,
May 19, 2012, 11:23:39 PM5/19/12
to
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.

Harry

unread,
May 20, 2012, 12:22:41 AM5/20/12
to
Ed Morton wrote...

[...]
> ... does Oracle use BREs or EREs or Perl REs or something else?

I'm not sure.

>Let's assume EREs, then you'd want:
>
>^[ADU].*\^(Female|Male)$


$ echo Wuxyz^Female | tr [[:lower:]] [[:upper:]]
| egrep '^[ADU].*\^(Female|Male)$'

$

Yes! It also worked with my Oracle query tool.

Thanks

0 new messages