【发布时间】:2021-12-31 07:31:16
【问题描述】:
当以下字符串存在时,我想从内部提取特定字符串。我要提取的字符串是uuid。
但是不知道怎么填写正则表达式带上uuid。 uuid前后除了'/'和'-'怎么写?
const text = "hello_img/2021/12/27/uuid-c.jpg";
const reg = /\b\/u.*?-/g;
const matches = text.match(reg);
console.log(matches);
【问题讨论】:
-
试试:
/\bu[^-]+/ -
我们是在谈论
uuid作为字符串,还是将uuid替换为真正的 uuid? -
比如我写了uuid,真的是uuid。它可能是 v3。
-
你能举一些具体的例子吗(有很多变化)?
-
对于外行,就像我现在一样,“UUID”=Universally unique identifier。
标签: javascript regex