使用正则表达式从以下内容中提取出token-id的值?

使用正则表达式从以下内容中提取出token-id的值


慕哥9229398
浏览 1642回答 1
1回答

喵喵时光机

Javascript正则表达式/"token-id": "([^\"]*?)"/g&nbsp; 取第一捕获组的数据我给你一个Javascript语言的例子,你看看吧123456789101112<script&nbsp;type=text/javascript>&nbsp;var&nbsp;str='{&nbsp;"output":&nbsp;{&nbsp;"token-data":&nbsp;{&nbsp;"token-id":&nbsp;"YWRtaW5AYWMuYnJhbmNoOkFhY0AxMjM0NTY=",&nbsp;"expired-at":&nbsp;{&nbsp;"_value":&nbsp;"2017-05-02T23:36:39,597+08:00"}}}}';&nbsp;var&nbsp;regex=/"token-id":&nbsp;"([^\"]*?)"/g;&nbsp;var&nbsp;arr;&nbsp;while((arr=regex.exec(str))!=null){&nbsp;&nbsp;alert(arr[1]);&nbsp;}</script>&nbsp;运行结果YWRtaW5AYWMuYnJhbmNoOkFhY0AxMjM0NTY=
打开App,查看更多内容
随时随地看视频慕课网APP