regex - 用于从对话中删除所有日期时间的正则表达式

标签 regex swift

我在 swift 中有这样的新行字符串:

如何从该字符串中删除所有时间戳 (11.03.2016 22:46:16)?

最佳答案

最简单的方法是将字符类与 anchor 相结合:

^[\d. :]+(.+)
# anchor it to the beginning of the line
# only digits, spaces, dots and a colon allowed
# one or more times
# the (.+) brings you down the line

这里只带第一个捕获的组。
查看此方法的演示 here on regex101.com

关于regex - 用于从对话中删除所有日期时间的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36409386/

相关文章:

php - 如何删除前导和尾随非字母数字字符

ios - CloudKit 的单元测试

ios - 从 iOS swift 中的字典中删除值

ios - Swift 无法绕过我的 UIButton 的角

regex - 无法转义正则表达式中的反斜杠?

regex - 正则表达式 : "if" and single "="

Python Pyparsing : Capture comma-separated list inside parentheses ignoring inner parentheses

Java 正则表达式模式在 Linux (Amazon Beanstalk) 下不起作用

swift - 当一个切割另一个时两个圆之间的空间

ios - avplayer 在 seekToTime 上完成歌曲