如何Trim一个字符串到达某个字符(括号)
How Do I Trim A String When It Reaches A Certain Character (Parenthesis)
我有这个列,里面有一个字符串。我想要 return 一个显示提供程序列的结果,其中包含所有字符,但不包括第一个左括号之前的 space。
实现这一目标的最佳策略是什么?
即将 "NEAL K HANSEN (4406570001)" 变为 "NEAL K HANSEN" 等等。
使用regexp_replace()
,像这样:
regexp_replace(provider, ' \([^)]*\)', '')
例如:
=> select regexp_replace('"NEAL K HANSEN (4406570001)"', ' \([^)]*\)', '');
regexp_replace
-----------------
"NEAL K HANSEN"
(1 row)
函数调用将匹配 "a space, an open paren, any number of characters that is not a closing paren, and a closing paren" 的所有内容替换为空字符串(空字符串)。
我有这个列,里面有一个字符串。我想要 return 一个显示提供程序列的结果,其中包含所有字符,但不包括第一个左括号之前的 space。
实现这一目标的最佳策略是什么?
即将 "NEAL K HANSEN (4406570001)" 变为 "NEAL K HANSEN" 等等。
使用regexp_replace()
,像这样:
regexp_replace(provider, ' \([^)]*\)', '')
例如:
=> select regexp_replace('"NEAL K HANSEN (4406570001)"', ' \([^)]*\)', '');
regexp_replace
-----------------
"NEAL K HANSEN"
(1 row)
函数调用将匹配 "a space, an open paren, any number of characters that is not a closing paren, and a closing paren" 的所有内容替换为空字符串(空字符串)。