仅获取UUID而不是全部获取

时间:2019-12-04 14:08:41

标签: regex

我有以下日志消息:

"Record was found. Existing Id : 16786131-5d05-4545-92c6-3a24b92843bd Incoming Id : 16786131-5d05-4545-92c6-3a24b92843bd"

我正在使用以下正则表达式从消息中提取uuid:

\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b

如果我只想提取前缀为Existing Id :的uuid怎么办

我该怎么做?

https://rubular.com/r/icNcb88Z5mO2TN

1 个答案:

答案 0 :(得分:1)

类似\bExisting Id : ([a-f0-9-]+)\b

即:

word边界,文字字符串“ Existing Id:”,后跟集合中的> 0个重复(十六进制字母和数字以及-),然后是边界。