如何使用正则表达式简化此语句?
请假设您将以下语句存储在 VARCHAR2
中:
UPDATE PLUTO SET FIELD1='',FIELD2='',FIELD3='TIGER',FIELD4='',FIELD5='SCOTT';
我想编写一个正则表达式,通过删除所有设置为 NULL 的更新来简化前面的语句,因为它们是无用的(NULL 是默认语句),如下:
UPDATE PLUTO SET FIELD3='TIGER', FIELD5='SCOTT';
你能帮我吗?
我从来没有这么擅长正则表达式......!!
Please suppose you have the following statement stored in a VARCHAR2
:
UPDATE PLUTO SET FIELD1='',FIELD2='',FIELD3='TIGER',FIELD4='',FIELD5='SCOTT';
I would like to write a regular expression that simplifies the previous statement, by removing all the updates setting to NULL, because they are useless (NULL is the default statement), as follows:
UPDATE PLUTO SET FIELD3='TIGER', FIELD5='SCOTT';
Could you help me?
I have never been so good with regular expressions...!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这怎么样?它将删除所有的FIELD#=''(有或没有final,)
这是一个正则表达式备忘单:
http://psoug.org/snippet.htm/Regular_Expressions_Regex_Cheat_Sheet_856.ht m?PHPSESSID=7238be874ab99d0731a9da64f2dbafd8
关于 Oracle 正则表达式的良好资源
http://psoug.org/snippet/Regular-Expressions---REGEXP_REPLACE_882.htm
how's this? it will remove all FIELD#='' (with or without final ,)
here's a regular expression cheat sheet:
http://psoug.org/snippet.htm/Regular_Expressions_Regex_Cheat_Sheet_856.htm?PHPSESSID=7238be874ab99d0731a9da64f2dbafd8
and good resource on Oracle's Regular Expression
http://psoug.org/snippet/Regular-Expressions---REGEXP_REPLACE_882.htm
我相信这应该能让你得到你想要的,但可能有更好的方法,因为我也不是最擅长正则表达式的:
I believe this should get you what you want, but there may be a better way, as I am not the best with regexp either: