我有一个URL字符串
http://apistaging.yoolk.com/listings/F7B519E8-135C-43D0-A35F-764B582EDC48?domain_name=cambodiastaging.yoolk.com&display=basic
我想通过在JavaScript中使用正则表达式,仅获取此URL中的uuid
F7B519E8-135C-43D0-A35F-764B582EDC48
。我该如何做?请给我一些建议。谢谢大家。
我有一个URL字符串
http://apistaging.yoolk.com/listings/F7B519E8-135C-43D0-A35F-764B582EDC48?domain_name=cambodiastaging.yoolk.com&display=basic
F7B519E8-135C-43D0-A35F-764B582EDC48
。我该如何做?请给我一些建议。/((\w{4,12}-?)){5}/.exec(URL)[0]
var url = 'http://apistaging.yoolk.com/listings/F7B519E8-135C-43D0-A35F-764B582EDC48?domain_name=cambodiastaging.yoolk.com&display=basi',
matches = url.match(/listings\/([A-F\d-]+)\?/),
UUID = matches[1];
console.log(UUID); // F7B519E8-135C-43D0-A35F-764B582EDC48
我会用分割来做。
var uri = 'http://apistaging.yoolk.com/listings/F7B519E8-135C-43D0-A35F-764B582EDC48?domain_name=cambodiastaging.yoolk.com&display=basic'
uri.split('?')[0].split('/')[4]