SF1
SF1

Reputation: 27

How to write oracle sql to look for special characters

I'm trying to search a varchar string for these specific characters. ^$<> I tried using regexp_like(), but I can't figure out to only show the records that have those characters (since ^ and $ are used to determine something else in that function).
My data is a title field - so I only want to see the titles that have any of those characters. Thanks!

Upvotes: 0

Views: 323

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627468

You should use

where col REGEXP_LIKE '[$^<>]'

Note that ^ is a negation marker when used as the first symbol inside a bracket expression, so it should be placed at the non-initial position.

Also, there is no need to add any .* to the pattern since REGEXP_LIKE is able to perform a partial match (i.e. there is no obligation to match the whole record).

Upvotes: 1

Related Questions