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.
我需要清理包含来自 JSON 文档的 BELL 字符的字符串。我不明白如何定义正则表达式模式
import scala.util.matching.Regex def sanitize(dirtyString: String): String = { val pattern = "\007" // Octal definition or other ??? pattern.r.replaceAllIn(dirtyString, "") }
有什么帮助吗?
试一试
dirtyString.replace("\u0007", "");
这比使用正则表达式来完成此类任务要快得多。
请参阅用字符代码而不是正则表达式替换字符串?