Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
要删除所有非字母数字字符,正则表达式将是
x = regexp_replace(somestring, '[^a-zA-Z0-9]+', '', 'g')
但是如果我想保持下划线不变呢?
然后你需要使用:
x = regexp_replace(somestring, '\W+', '', 'g')
\W是相同的[^a-zA-Z0-9_]
\W
[^a-zA-Z0-9_]
如何使用 '\W+' 替换所有非 az 和 0-9 留下 _
所以