postgres regexp_replace只允许a-z和A-Z [英] postgres regexp_replace want to allow only a-z and A-Z

查看:106
本文介绍了postgres regexp_replace只允许a-z和A-Z的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在字符串的表列中,我们可以有数字/特殊字符/空格。
我想用空字符替换数字/特殊字符/空白,我看到有一个名为 regexp_replace 的函数,但是如何使用不多的用户友好帮助例如,我想使用以下字符串。

In a table column in string we can have numbers/special chars/white spaces. I want to replace numbers/special chars/white space with empty char, i see there is function named regexp_replace but how to use not much user friendly help avaialble for example i want to use following string.

String = 'abc$wanto&toremove#special~chars'

我想删除字符串中的所有特殊字符和数字,只允许 az AZ 其余字符应替换为''怎么做?

I want to remove all special chars and numbers from above string want to allow only a-z and A-Z rest of chars should be replaced with '' how to do that ?

推荐答案

select regexp_replace('abc$wanto&toremove#special~chars', '[^a-zA-Z]', '', 'g')

这篇关于postgres regexp_replace只允许a-z和A-Z的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆