Redian新闻
>
delete characters between parentheses?
avatar
delete characters between parentheses?# Database - 数据库
a*t
1
Hi,
I can do this in sql server -
select * where cln1 like '%(%)%'
however, if I want to delete the characters between parentheses, I can't use
replace( cln1, '(%)','').
Anyone knows how to do it?
Thanks a lot!
avatar
B*g
2
like followed by a pattern.
replace use string.
I know how to do it using regular expression in oracle 10g+.
As I know you have to create your own function to do regular expression
replace in sql server 2005(I may be wrong)

use

【在 a*******t 的大作中提到】
: Hi,
: I can do this in sql server -
: select * where cln1 like '%(%)%'
: however, if I want to delete the characters between parentheses, I can't use
: replace( cln1, '(%)','').
: Anyone knows how to do it?
: Thanks a lot!

avatar
a*t
3
Thanks for your response.
Exactly, the wildcard character doesn't work for replace in sql server 2005.
What is the logic in oracle 10g+ for this please?
avatar
B*g
4
呵呵, I hate regular expression.
select col, regexp_replace(col, '[\(]{1}[^)]*[\)]{1}', '')
from table
where col like '%(%)%'

2005.

【在 a*******t 的大作中提到】
: Thanks for your response.
: Exactly, the wildcard character doesn't work for replace in sql server 2005.
: What is the logic in oracle 10g+ for this please?

avatar
j*n
5
一个笨点的招:
用select 找出来放到 temp table, 然后一个个repalce.
avatar
B*g
6
为啥sql server不搞regular expression?

【在 j*****n 的大作中提到】
: 一个笨点的招:
: 用select 找出来放到 temp table, 然后一个个repalce.

avatar
j*n
7
其实也有,看看online book 上面介绍了的。我只是很少做类似的工作,不是太熟罢了。
2005 对 regular expression 也作了相应的加强。

【在 B*****g 的大作中提到】
: 为啥sql server不搞regular expression?
avatar
a*t
8
Thanks so much! This is helpful!
avatar
a*t
9
get character index of '('
get character index of ')'
get substring until '('
get substring starting from ')'
new string = the two above substring add together
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。