• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 823
  • Last Modified:

Oracle RegExp to Find String

Hello,

I am looking for a regexp in Oracle sql to find the following conditions.

(char)-(space)
or
(space)-(char)

The middle character is a - (dash). Basically I want any rows that have a dash with a character, including space, next to the dash on either side.

Thank you,

Bob
0
bobcaputo
Asked:
bobcaputo
  • 2
1 Solution
 
sdstuberCommented:
select * from yourtable
where regexp_like(yourstring,'[^-]-[^-] ')

this will find any dash surrounded by non-dashes
0
 
sdstuberCommented:
if you specifically want to find space and non-space characters surrounding a dash
then


select * from yourtable
where regexp_like(yourstring,'[^ -]- | -[^ -] ')

this will find dashes with a space on one side
and a non-space-non-dash on the other side
0
 
bobcaputoAuthor Commented:
Thank you, now that I see it, it is much clearer and obvious!!!!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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