正则表达式改进
Regex improving
我需要帮助改进我的正则表达式
这个给你:
https://regex101.com/r/I2c53h/3
我有文字:
#1234 10% activity@timing:information and other activity2@timing:adws
#3132 10% testing@1.10:test message frontend@44min:other comments
#3132 10% testing@1.10:test message
#3132 10% testing@1.10
并使用这个正则表达式:
(?<!\S)(\w+)@([\w.]*)\:?(\w+(?:\h\w+)*)(?!\S)
我需要修改它。我想在 第 3 组 中不仅使用单词字符,而且使用所有可能的符号,除了 @,因为它是下一组的符号。
我想让你看看最后一个字符串。在这里你可以看到,那个角色 0 去了 3rd group。我需要它去第二组。
提前致谢!
您可以将正则表达式更改为:
(?<!\S)(\w+)@([\w.]+)(?::([^@\n]+)(?!\S))?
否定字符 class [^@\n]
匹配任何非 @
且非 \n
的字符
我需要帮助改进我的正则表达式 这个给你: https://regex101.com/r/I2c53h/3
我有文字:
#1234 10% activity@timing:information and other activity2@timing:adws
#3132 10% testing@1.10:test message frontend@44min:other comments
#3132 10% testing@1.10:test message
#3132 10% testing@1.10
并使用这个正则表达式:
(?<!\S)(\w+)@([\w.]*)\:?(\w+(?:\h\w+)*)(?!\S)
我需要修改它。我想在 第 3 组 中不仅使用单词字符,而且使用所有可能的符号,除了 @,因为它是下一组的符号。
我想让你看看最后一个字符串。在这里你可以看到,那个角色 0 去了 3rd group。我需要它去第二组。
提前致谢!
您可以将正则表达式更改为:
(?<!\S)(\w+)@([\w.]+)(?::([^@\n]+)(?!\S))?
否定字符 class [^@\n]
匹配任何非 @
且非 \n