Durai
Durai

Reputation: 33

Regexp_Like to get exact string match

How can i get exact string match by using REGEXP_LIKE. When i use the below sql, it always returns 'True' when i try to match for 'SETID_EMPL_CLASS' as whole string.

select 'True'
from Dual
where REGEXP_like ('SETID_EMPL_CLASS', '(^|;)' || upper('ethnic_grp_cd|empl_type|full_part_time|comp_frequenc|empl_class'));

Thanks

Upvotes: 2

Views: 3168

Answers (1)

wolfrevokcats
wolfrevokcats

Reputation: 2100

To get the full string match (not just a part of a string) with regexp_like you should add ^ and $ to the set of alternatives:

select 'True'
from Dual 
where REGEXP_like ('SETID_EMPL_CLASS', upper('^(ethnic_grp_cd|empl_type|full_part_time|comp_frequenc|empl_class)$'));

Upvotes: 4

Related Questions