我想从名字中删除诸如Dr.,Jr.的头衔。 Regexp_replace
应该搜索并删除Jr先生,搜索应该不区分大小写,最终输出不应包含.
或,
或名称中的多余空格。
select regexp_replace('DR. Mr. Mr Dr Radha Jr Jr. Krishnan Jr.','(Dr|Mr|Jr)(\W|\w|$|,)',1,0,'i')
from dual
我收到无效的号码错误。
答案 0 :(得分:0)
您忘记了在pattern和1之间替换什么
shopify.api_version.VersionNotFoundError.
TRACEBACK (MOST RECENT CALL LAST)
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\92344\Anaconda3\lib\site-packages\flask\app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\92344\Downloads\HelloShopify-master\helloshopify\shopify_bp\views.py", line 36, in install
session = shopify.Session(shop_url)
File "C:\Users\92344\Anaconda3\lib\site-packages\shopify\session.py", line 47, in __init__
self.version = ApiVersion.coerce_to_version(version)
File "C:\Users\92344\Anaconda3\lib\site-packages\shopify\api_version.py", line 18, in coerce_to_version
raise VersionNotFoundError
shopify.api_version.VersionNotFoundError
答案 1 :(得分:0)
以下查询将删除多个空白并也修剪前导空格:
SELECT TRIM(REGEXP_REPLACE(
REGEXP_REPLACE('DR. Mr. Mr Dr Radha Jr Jr. Krishnan Jr.', '(Dr|Mr|Jr)(\W|\w|$|,)', '', 1, 0, 'i')
, ' {2,}', ' ')) AS "Result"
FROM Dual
它将返回结果为Radha Krishnan
答案 2 :(得分:0)
您的解决方案缺少两个方面。
更重要的是,您可以从名称中删除开头的“标题”:
select regexp_replace('DR. Mr. Mr Dr Dradha Jr Jr. Mrishnan Jr.','(Dr|Mr|Jr)(\W|\w|$|,)','',1,0,'i')
from dual
返回不期望的结果
dha shnan
补救措施是在标题之后仅允许非单词字符(\W
)和行尾($
) 。< / p>
如果您在标题前加了可选空格或行首(^
)(em),则摆脱了第二个问题,即删除标题后剩下的空格
select regexp_replace('DR. Mr. Mr Dr Dradha Jr Jr. Mr, Mrishnan Jr.',
'( *|^)(Dr|Mr|Jr)(\W|$)','',1,0,'i')
from dual
Dradha Mrishnan