[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

REGEXP_LIKE ?? Should I use

I have been using the below code to do a key down filter using ajax but now I realize the regexp_like is not seeing the ( and ) as normal characters.
Should I be using this regexp_like here?
select group_name, group_id, rownum r from ( 
			 select group_name, group_id
			   from um_groups
			  where group_type_id = 2
			    and regexp_like( group_name,
				   nvl(l_search,group_name), 'i' )
			    and nvl(instr(':'||l_selected||':',
					 ':'||group_id||':'),0)=0 
			    and status_id = nvl(l_status_filter,1)
			  order by 1)

Open in new window

0
bcarlis
Asked:
bcarlis
  • 2
1 Solution
 
sdstuberCommented:
if "l_search"  is a string like  this


'(something)'     the ()  are regular expression delimiters to identify "something" as pattern.

if you want to search for the parentheses characters themselves.  you must prefix them with "\"

try modifying l_search like this...

replace(replace(l_search,'(','\('),')','\')
0
 
sdstuberCommented:
but...

if the only thing you're trying to do is an existence check of some substring  "like" or "instr" might be better, even with an UPPER to handle your case insenstive searching


and instr(upper(group_name), upper(nvl(l_search,group_name))) > 0


regexp are fairly expensive compared to other string functions. Unless your string parsing is complex enough to warrant the cost of regular expressions, I'd avoid them.
0
 
bcarlisAuthor Commented:
Thank you!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now