我尝试创建regex,它通过选择忽略斜杠符号。例如,我在我的专栏“things”中有这样的内容:
arbit
t/obt
t/comp
t/dor
cramp
pod我只能打字: pod,tdor,arbit,tcomp
我试过使用"REGEXP_SUBSTR"-Expression,但可能不适合这个问题。
发布于 2018-06-08 07:54:49
假设您有下表:
$ 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您可以使用以下不使用regex的简单replace:
select Replace(Lastname,'/','') from persons;
-- you can omit the replacement part select Replace(Lastname,'/') from persons;
--Replace(Lastname,'/','')--
arbit
tobt
tcomp
tdor
cramp
pod如果您确实需要使用regex进行复杂的搜索和替换:(在您的情况下这是不必要的)
$ select REGEXP_REPLACE(Lastname, '/', '') from persons;
--REGEXP_REPLACE(Lastname, '/', '')--
arbit
tobt
tcomp
tdor
cramp
pod您还可以省略替换部分,因为它是空的:
select REGEXP_REPLACE(Lastname, '/') from persons发布于 2018-06-08 07:43:21
您可以使用简单的替换来删除/
SELECT things, REPLACE(things, '/', '')
FROM tabhttps://stackoverflow.com/questions/50755599
复制相似问题