0

I try to create regex, which ignores slash-sign by selection. For example i have content like this in my column "things":

arbit
t/obt 
t/comp 
t/dor
cramp
pod

I only can type: pod, tdor, arbit, tcomp

I have tried with "REGEXP_SUBSTR"-Expression, but maybe it is not appropriate for this issue.

1
  • what do you want as output? Commented Jun 8, 2018 at 7:41

2 Answers 2

2

Imagine that you have the following table:

$ select * from PERSONS;

PersonID LastName FirstName ADDRESS CITY
1          arbit     null      null  null           
2          t/obt     null      null  null           
3          t/comp    null      null  null           
4          t/dor     null      null  null           
5          cramp     null      null  null           
6          pod       null      null  null

You can use the following simple replace that does not use regex:

select Replace(Lastname,'/','') from persons;
-- you can omit the replacement part select Replace(Lastname,'/') from persons;

--Replace(Lastname,'/','')--    
arbit
tobt
tcomp
tdor
cramp
pod

If you really need to do a complex search and replace that uses regex: (this is not necessary in your case)

$ select REGEXP_REPLACE(Lastname, '/', '') from persons;

--REGEXP_REPLACE(Lastname, '/', '')--
arbit
tobt
tcomp
tdor
cramp
pod

You can also omit the replacement part since it is empty:

select REGEXP_REPLACE(Lastname, '/') from persons
Sign up to request clarification or add additional context in comments.

Comments

2

You could use simple replace to remove /:

SELECT things, REPLACE(things, '/', '')
FROM tab

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.