正则表达式模式,用于用空格替换所有特殊字符,但引号之间的字符除外 [英] Regex pattern for replacing all special characters with space except those betwee quotes
本文介绍了正则表达式模式,用于用空格替换所有特殊字符,但引号之间的字符除外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在 salesforce 中使用 Regex 模式来替换字符串中的所有特殊字符,但引号之间的字符除外,例如...
I need a Regex pattern in salesforce to replace all special characters in a string except those between quotes like..
输入:hai@#$welcome to 'World@#$'
输出:hai Welcome to 'World@#$'
我尝试了以下方法,但没有按预期工作:
I tried the following, but it's not working as expected:
'[^\\w((?<=\')(.*)(?=\'))]'
推荐答案
您的搜索正则表达式应该是:
Your search regex should be:
[^\w\s'](?=(([^']*'){2})*[^']*$)
并替换为:
" "
在线演示:http://regex101.com/r/lC6zG5
说明:
这篇关于正则表达式模式,用于用空格替换所有特殊字符,但引号之间的字符除外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文